src/world.js
function(options) {
        options = options || {};
        var immediately = options.immediately || false;
        var layout = options.layout || $.DEFAULT_SETTINGS.collectionLayout;
        var rows = options.rows || $.DEFAULT_SETTINGS.collectionRows;
        var columns = options.columns || $.DEFAULT_SETTINGS.collectionColumns;
        var tileSize = options.tileSize || $.DEFAULT_SETTINGS.collectionTileSize;
        var tileMargin = options.tileMargin || $.DEFAULT_SETTINGS.collectionTileMargin;
        var increment = tileSize + tileMargin;
        var wrap;
        if (!options.rows && columns) {
            wrap = columns;
        } else {
            wrap = Math.ceil(this._items.length / rows);
        }
        var x = 0;
        var y = 0;
        var item, box, width, height, position;

        this.setAutoRefigureSizes(false);
        for (var i = 0; i < this._items.length; i++) {
            if (i && (i % wrap) === 0) {
                if (layout === 'horizontal') {
                    y += increment;
                    x = 0;
                } else {
                    x += increment;
                    y = 0;
                }
            }

            item = this._items[i];
            box = item.getBounds();
            if (box.width > box.height) {
                width = tileSize;
            } else {
                width = tileSize * (box.width / box.height);
            }

            height = width * (box.height / box.width);
            position = new $.Point(x + ((tileSize - width) / 2),
                y + ((tileSize - height) / 2));

            item.setPosition(position, immediately);
            item.setWidth(width, immediately);

            if (layout === 'horizontal') {
                x += increment;
            } else {
                y += increment;
            }
        }
        this.setAutoRefigureSizes(true);
    }
function(options) {
        options = options || {};
        var immediately = options.immediately || false;
        var layout = options.layout || $.DEFAULT_SETTINGS.collectionLayout;
        var rows = options.rows || $.DEFAULT_SETTINGS.collectionRows;
        var columns = options.columns || $.DEFAULT_SETTINGS.collectionColumns;
        var tileSize = options.tileSize || $.DEFAULT_SETTINGS.collectionTileSize;
        var tileMargin = options.tileMargin || $.DEFAULT_SETTINGS.collectionTileMargin;
        var increment = tileSize + tileMargin;
        var wrap;
        if (!options.rows && columns) {
            wrap = columns;
        } else {
            wrap = Math.ceil(this._items.length / rows);
        }
        var x = 0;
        var y = 0;
        var item, box, width, height, position;

        this.setAutoRefigureSizes(false);
        for (var i = 0; i < this._items.length; i++) {
            if (i && (i % wrap) === 0) {
                if (layout === 'horizontal') {
                    y += increment;
                    x = 0;
                } else {
                    x += increment;
                    y = 0;
                }
            }

            item = this._items[i];
            box = item.getBounds();
            if (box.width > box.height) {
                width = tileSize;
            } else {
                width = tileSize * (box.width / box.height);
            }

            height = width * (box.height / box.width);
            position = new $.Point(x + ((tileSize - width) / 2),
                y + ((tileSize - height) / 2));

            item.setPosition(position, immediately);
            item.setWidth(width, immediately);

            if (layout === 'horizontal') {
                x += increment;
            } else {
                y += increment;
            }
        }
        this.setAutoRefigureSizes(true);
    }
function ( options ) { options = options || { } ; var immediately = options . immediately || false ; var layout = options . layout || $ . DEFAULT_SETTINGS . collectionLayout ; var rows = options . rows || $ . DEFAULT_SETTINGS . collectionRows ; var columns = options . columns || $ . DEFAULT_SETTINGS . collectionColumns ; var tileSize = options . tileSize || $ . DEFAULT_SETTINGS . collectionTileSize ; var tileMargin = options . tileMargin || $ . DEFAULT_SETTINGS . collectionTileMargin ; var increment = tileSize + tileMargin ; var wrap ; if ( ! options . rows && columns ) { wrap = columns ; } else { wrap = Math . ceil ( this . _items . length / rows ) ; } var x = 0 ; var y = 0 ; var item , box , width , height , position ; this . setAutoRefigureSizes ( false ) ; for ( var i = 0 ; i < this . _items . length ; i ++ ) { if ( i && ( i % wrap ) === 0 ) { if ( layout === 'horizontal' ) { y += increment ; x = 0 ; } else { x += increment ; y = 0 ; } } item = this . _items [ i ] ; box = item . getBounds ( ) ; if ( box . width > box . height ) { width = tileSize ; } else { width = tileSize * ( box . width / box . height ) ; } height = width * ( box . height / box . width ) ; position = new $ . Point ( x + ( ( tileSize - width ) / 2 ) , y + ( ( tileSize - height ) / 2 ) ) ; item . setPosition ( position , immediately ) ; item . setWidth ( width , immediately ) ; if ( layout === 'horizontal' ) { x += increment ; } else { y += increment ; } } this . setAutoRefigureSizes ( true ) ; }
Arranges all of the TiledImages with the specified settings.
@param {Object} options - Specifies how to arrange.
@param {Boolean} [options.immediately=false] - Whether to animate to the new arrangement.
@param {String} [options.layout] - See collectionLayout in {@link OpenSeadragon.Options}.
@param {Number} [options.rows] - See collectionRows in {@link OpenSeadragon.Options}.
@param {Number} [options.columns] - See collectionColumns in {@link OpenSeadragon.Options}.
@param {Number} [options.tileSize] - See collectionTileSize in {@link OpenSeadragon.Options}.
@param {Number} [options.tileMargin] - See collectionTileMargin in {@link OpenSeadragon.Options}.
@fires OpenSeadragon.World.event:metrics-change
Arranges all of the TiledImages with the specified settings .