From c7971419e2f27588cde258e92775af8244e8392d Mon Sep 17 00:00:00 2001 From: Mark Salsbery Date: Fri, 22 Nov 2013 17:07:44 -0800 Subject: [PATCH 1/4] Added pollForResize option Defaults to true. --- changelog.txt | 1 + src/openseadragon.js | 4 ++++ src/viewer.js | 18 ++++++++++-------- src/viewport.js | 5 +++-- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/changelog.txt b/changelog.txt index 01a3900f..0ae90cd2 100644 --- a/changelog.txt +++ b/changelog.txt @@ -56,6 +56,7 @@ OPENSEADRAGON CHANGELOG * Viewer.innerTracker.scrollHandler: preventDefaultAction == true prevents viewer zooming on mousewheel/pinch * Fixed: IE8 error with custom buttons - "Object doesn't support this action" (#279) * Support IIIF servers that don't report tile dimensions (#286) +* Added a pollForResize option. Default is true. When set to false, the viewer takes no action when its container element is resized. 0.9.131: diff --git a/src/openseadragon.js b/src/openseadragon.js index 4a1fb29d..e4a05795 100644 --- a/src/openseadragon.js +++ b/src/openseadragon.js @@ -174,6 +174,9 @@ * image though it is less effective visually if the HTML5 Canvas is not * availble on the viewing device. * + * @param {Boolean} [options.pollForResize=true] + * Set to false to prevent polling for viewer size changes. Useful for providing custom resize behavior. + * * @param {Number} [options.visibilityRatio=0.5] * The percentage ( as a number from 0 to 1 ) of the source image which * must be kept within the viewport. If the image is dragged beyond that @@ -532,6 +535,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){ minZoomImageRatio: 0.9, //-> closer to 0 allows zoom out to infinity maxZoomPixelRatio: 1.1, //-> higher allows 'over zoom' into pixels pixelsPerWheelLine: 40, + pollForResize: true, //DEFAULT CONTROL SETTINGS showSequenceControl: true, //SEQUENCE diff --git a/src/viewer.js b/src/viewer.js index f528b411..82927b18 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -1657,14 +1657,16 @@ function updateOnce( viewer ) { //viewer.profiler.beginUpdate(); - containerSize = _getSafeElemSize( viewer.container ); - if ( !containerSize.equals( THIS[ viewer.hash ].prevContainerSize ) ) { - // maintain image position - var oldBounds = viewer.viewport.getBounds(); - var oldCenter = viewer.viewport.getCenter(); - resizeViewportAndRecenter(viewer, containerSize, oldBounds, oldCenter); - THIS[ viewer.hash ].prevContainerSize = containerSize; - THIS[ viewer.hash ].forceRedraw = true; + if ( viewer.pollForResize ) { + containerSize = _getSafeElemSize( viewer.container ); + if ( !containerSize.equals( THIS[ viewer.hash ].prevContainerSize ) ) { + // maintain image position + var oldBounds = viewer.viewport.getBounds(); + var oldCenter = viewer.viewport.getCenter(); + resizeViewportAndRecenter(viewer, containerSize, oldBounds, oldCenter); + THIS[ viewer.hash ].prevContainerSize = containerSize; + THIS[ viewer.hash ].forceRedraw = true; + } } animated = viewer.viewport.update(); diff --git a/src/viewport.js b/src/viewport.js index 12fbd956..c4cea72f 100644 --- a/src/viewport.js +++ b/src/viewport.js @@ -611,14 +611,15 @@ $.Viewport.prototype = { resize: function( newContainerSize, maintain ) { var oldBounds = this.getBounds(), newBounds = oldBounds, - widthDeltaFactor = newContainerSize.x / this.containerSize.x; + widthDeltaFactor; this.containerSize = new $.Point( newContainerSize.x, newContainerSize.y ); - if (maintain) { + if ( maintain ) { + widthDeltaFactor = newContainerSize.x / this.containerSize.x; newBounds.width = oldBounds.width * widthDeltaFactor; newBounds.height = newBounds.width / this.getAspectRatio(); } From 190b4425ed53aa9e079f20a4ff5b06fb1dac3692 Mon Sep 17 00:00:00 2001 From: Mark Salsbery Date: Sat, 23 Nov 2013 08:21:08 -0800 Subject: [PATCH 2/4] Renamed pollForResize to noResizePolling Flipped truthiness...default of false is better for backward compatibility --- changelog.txt | 2 +- src/openseadragon.js | 6 +++--- src/viewer.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/changelog.txt b/changelog.txt index 0ae90cd2..41091585 100644 --- a/changelog.txt +++ b/changelog.txt @@ -56,7 +56,7 @@ OPENSEADRAGON CHANGELOG * Viewer.innerTracker.scrollHandler: preventDefaultAction == true prevents viewer zooming on mousewheel/pinch * Fixed: IE8 error with custom buttons - "Object doesn't support this action" (#279) * Support IIIF servers that don't report tile dimensions (#286) -* Added a pollForResize option. Default is true. When set to false, the viewer takes no action when its container element is resized. +* Added a noResizePolling option. Default is false. When set to true, the viewer takes no action when its container element is resized. 0.9.131: diff --git a/src/openseadragon.js b/src/openseadragon.js index e4a05795..cccd2602 100644 --- a/src/openseadragon.js +++ b/src/openseadragon.js @@ -174,8 +174,8 @@ * image though it is less effective visually if the HTML5 Canvas is not * availble on the viewing device. * - * @param {Boolean} [options.pollForResize=true] - * Set to false to prevent polling for viewer size changes. Useful for providing custom resize behavior. + * @param {Boolean} [options.noResizePolling=false] + * Set to true to prevent polling for viewer size changes. Useful for providing custom resize behavior. * * @param {Number} [options.visibilityRatio=0.5] * The percentage ( as a number from 0 to 1 ) of the source image which @@ -535,7 +535,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){ minZoomImageRatio: 0.9, //-> closer to 0 allows zoom out to infinity maxZoomPixelRatio: 1.1, //-> higher allows 'over zoom' into pixels pixelsPerWheelLine: 40, - pollForResize: true, + noResizePolling: false, //DEFAULT CONTROL SETTINGS showSequenceControl: true, //SEQUENCE diff --git a/src/viewer.js b/src/viewer.js index 82927b18..57cdd397 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -1657,7 +1657,7 @@ function updateOnce( viewer ) { //viewer.profiler.beginUpdate(); - if ( viewer.pollForResize ) { + if ( !viewer.noResizePolling ) { containerSize = _getSafeElemSize( viewer.container ); if ( !containerSize.equals( THIS[ viewer.hash ].prevContainerSize ) ) { // maintain image position From 952fcca46ed533c8b81e524e5bdc99c57f2392ee Mon Sep 17 00:00:00 2001 From: Mark Salsbery Date: Mon, 25 Nov 2013 10:27:03 -0800 Subject: [PATCH 3/4] Renamed noResizePolling to autoResize --- changelog.txt | 2 +- src/openseadragon.js | 4 ++-- src/viewer.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/changelog.txt b/changelog.txt index 41091585..aac1fa7c 100644 --- a/changelog.txt +++ b/changelog.txt @@ -56,7 +56,7 @@ OPENSEADRAGON CHANGELOG * Viewer.innerTracker.scrollHandler: preventDefaultAction == true prevents viewer zooming on mousewheel/pinch * Fixed: IE8 error with custom buttons - "Object doesn't support this action" (#279) * Support IIIF servers that don't report tile dimensions (#286) -* Added a noResizePolling option. Default is false. When set to true, the viewer takes no action when its container element is resized. +* Added a autoResize option. Default is true. When set to false, the viewer takes no action when its container element is resized. 0.9.131: diff --git a/src/openseadragon.js b/src/openseadragon.js index cccd2602..e97f4e05 100644 --- a/src/openseadragon.js +++ b/src/openseadragon.js @@ -174,7 +174,7 @@ * image though it is less effective visually if the HTML5 Canvas is not * availble on the viewing device. * - * @param {Boolean} [options.noResizePolling=false] + * @param {Boolean} [options.autoResize=true] * Set to true to prevent polling for viewer size changes. Useful for providing custom resize behavior. * * @param {Number} [options.visibilityRatio=0.5] @@ -535,7 +535,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){ minZoomImageRatio: 0.9, //-> closer to 0 allows zoom out to infinity maxZoomPixelRatio: 1.1, //-> higher allows 'over zoom' into pixels pixelsPerWheelLine: 40, - noResizePolling: false, + autoResize: true, //DEFAULT CONTROL SETTINGS showSequenceControl: true, //SEQUENCE diff --git a/src/viewer.js b/src/viewer.js index 57cdd397..ab2dc8f4 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -1657,7 +1657,7 @@ function updateOnce( viewer ) { //viewer.profiler.beginUpdate(); - if ( !viewer.noResizePolling ) { + if ( viewer.autoResize ) { containerSize = _getSafeElemSize( viewer.container ); if ( !containerSize.equals( THIS[ viewer.hash ].prevContainerSize ) ) { // maintain image position From d8006e96c940fb3b750e92a37964a990cf50e6cc Mon Sep 17 00:00:00 2001 From: Mark Salsbery Date: Mon, 25 Nov 2013 12:10:19 -0800 Subject: [PATCH 4/4] autoSize doc fixups --- changelog.txt | 2 +- src/openseadragon.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/changelog.txt b/changelog.txt index aac1fa7c..e2685843 100644 --- a/changelog.txt +++ b/changelog.txt @@ -56,7 +56,7 @@ OPENSEADRAGON CHANGELOG * Viewer.innerTracker.scrollHandler: preventDefaultAction == true prevents viewer zooming on mousewheel/pinch * Fixed: IE8 error with custom buttons - "Object doesn't support this action" (#279) * Support IIIF servers that don't report tile dimensions (#286) -* Added a autoResize option. Default is true. When set to false, the viewer takes no action when its container element is resized. +* Added an autoResize option. Default is true. When set to false, the viewer takes no action when its container element is resized. 0.9.131: diff --git a/src/openseadragon.js b/src/openseadragon.js index e97f4e05..c011c2d3 100644 --- a/src/openseadragon.js +++ b/src/openseadragon.js @@ -175,7 +175,7 @@ * availble on the viewing device. * * @param {Boolean} [options.autoResize=true] - * Set to true to prevent polling for viewer size changes. Useful for providing custom resize behavior. + * Set to false to prevent polling for viewer size changes. Useful for providing custom resize behavior. * * @param {Number} [options.visibilityRatio=0.5] * The percentage ( as a number from 0 to 1 ) of the source image which