From 339401683f50dc679fa0d0e9be87b3510ed8290c Mon Sep 17 00:00:00 2001 From: Larissa Smith Date: Thu, 2 Jul 2015 13:20:57 -0600 Subject: [PATCH 1/2] Added configuration parameter to allow a horizontal layout that has a fixed number of columns or a vertical layout that has a fixed number of rows. --- src/openseadragon.js | 5 +++++ src/viewer.js | 1 + src/world.js | 9 ++++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/openseadragon.js b/src/openseadragon.js index e20926bd..64349972 100644 --- a/src/openseadragon.js +++ b/src/openseadragon.js @@ -559,6 +559,10 @@ * If collectionMode is true, specifies how many rows the grid should have. Use 1 to make a line. * If collectionLayout is 'vertical', specifies how many columns instead. * + * @property {Number} [collectionColumns=0] + * If collectionMode is true, specifies how many columns the grid should have. Use 1 to make a line. + * If collectionLayout is 'vertical', specifies how many rows instead. Ignored if collectionRows is not set to a falsy value. + * * @property {String} [collectionLayout='horizontal'] * If collectionMode is true, specifies whether to arrange vertically or horizontally. * @@ -1039,6 +1043,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){ //COLLECTION VISUALIZATION SETTINGS collectionRows: 3, //or columns depending on layout + collectionColumns: 0, //columns in horizontal layout, rows in vertical layout collectionLayout: 'horizontal', //vertical collectionMode: false, collectionTileSize: 800, diff --git a/src/viewer.js b/src/viewer.js index f93c8e23..01560f01 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -1318,6 +1318,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, _this.world.arrange({ immediately: queueItem.options.collectionImmediately, rows: _this.collectionRows, + columns: _this.collectionColumns, layout: _this.collectionLayout, tileSize: _this.collectionTileSize, tileMargin: _this.collectionTileMargin diff --git a/src/world.js b/src/world.js index c9e65225..73b28a67 100644 --- a/src/world.js +++ b/src/world.js @@ -281,6 +281,7 @@ $.extend( $.World.prototype, $.EventSource.prototype, /** @lends OpenSeadragon.W * @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 @@ -290,10 +291,16 @@ $.extend( $.World.prototype, $.EventSource.prototype, /** @lends OpenSeadragon.W 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 = Math.ceil(this._items.length / rows); + 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; From 57e6fdde900c08fc442e323e87d2117deba6cc6c Mon Sep 17 00:00:00 2001 From: Larissa Smith Date: Tue, 7 Jul 2015 14:09:49 -0600 Subject: [PATCH 2/2] Added tests for collectionColumns use by world.arrange. --- test/modules/world.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/modules/world.js b/test/modules/world.js index ce63f02a..0c5aebf7 100644 --- a/test/modules/world.js +++ b/test/modules/world.js @@ -213,6 +213,26 @@ checkBounds(new OpenSeadragon.Rect(0, 0, 1, 4), 'one vertical column'); + viewer.world.arrange({ + layout: 'horizontal', + rows: false, + columns: 3, + tileSize: 1, + tileMargin: 0.5 + }); + + checkBounds(new OpenSeadragon.Rect(0, 0, 4, 1), 'three horizontal columns (one horizontal row)'); + + viewer.world.arrange({ + layout: 'vertical', + rows: false, + columns: 3, + tileSize: 1, + tileMargin: 0.5 + }); + + checkBounds(new OpenSeadragon.Rect(0, 0, 1, 4), 'three vertical rows (one vertical column)'); + start(); });