From 6d3b582e5898623c4eeb0993967b77150eb20187 Mon Sep 17 00:00:00 2001 From: Shaun Whitely Date: Sat, 29 Aug 2015 16:46:56 +1000 Subject: [PATCH] Removed allowZoomToConstraintsOnResize and made the new resize behaviour the default --- src/openseadragon.js | 6 ------ src/viewer.js | 30 +++++++----------------------- 2 files changed, 7 insertions(+), 29 deletions(-) diff --git a/src/openseadragon.js b/src/openseadragon.js index d2235381..6eb8d09a 100644 --- a/src/openseadragon.js +++ b/src/openseadragon.js @@ -255,11 +255,6 @@ * @property {Boolean} [preserveImageSizeOnResize=false] * Set to true to have the image size preserved when the viewer is resized. This requires autoResize=true (default). * - * @property {Boolean} [allowZoomToConstraintsOnResize=false] - * Set to true to allow the image to remain zoomed out past the home zoom level during resize. - * If false the image will be zoomed in if necessary such that it touches the edge of the viewer. - * This requires autoResize=true (default). - * * @property {Number} [pixelsPerWheelLine=40] * For pixel-resolution scrolling devices, the number of pixels equal to one scroll line. * @@ -1000,7 +995,6 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){ pixelsPerWheelLine: 40, autoResize: true, preserveImageSizeOnResize: false, // requires autoResize=true - allowZoomToConstraintsOnResize: false, // requires autoResize=true //DEFAULT CONTROL SETTINGS showSequenceControl: true, //SEQUENCE diff --git a/src/viewer.js b/src/viewer.js index 0ed8b9ed..1e2a2a9d 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -2947,31 +2947,15 @@ function resizeViewportAndRecenter( viewer, containerSize, oldBounds, oldCenter viewport.resize( containerSize, true ); - var newWidth = oldBounds.width; - var newHeight = oldBounds.height; - - if (!viewer.allowZoomToConstraintsOnResize) { - var worldBounds = viewer.world.getHomeBounds(); - if (oldBounds.width > worldBounds.width) { - newWidth = worldBounds.width; - } - if (oldBounds.height > worldBounds.height) { - newHeight = worldBounds.height; - } - } - var newBounds = new $.Rect( - oldCenter.x - ( newWidth / 2.0 ), - oldCenter.y - ( newHeight / 2.0 ), - newWidth, - newHeight - ); + oldCenter.x - ( oldBounds.width / 2.0 ), + oldCenter.y - ( oldBounds.height / 2.0 ), + oldBounds.width, + oldBounds.height + ); - if (viewer.allowZoomToConstraintsOnResize) { - viewport.fitBoundsWithConstraints( newBounds, true ); - } else { - viewport.fitBounds( newBounds, true ); - } + // let the viewport decide if the bounds are too big or too small + viewport.fitBoundsWithConstraints( newBounds, true ); } function drawWorld( viewer ) {