Added configuration parameter: preserveImageSizeOnResize to preserve the default behavior.

Changed fitBounds to fitBoundsWithConstraints as per Ian's instructions.
This commit is contained in:
Grant Echols 2015-06-23 10:55:57 -06:00
parent 57c06a9a19
commit fb21dabd76
2 changed files with 7 additions and 2 deletions

View File

@ -252,6 +252,9 @@
* @property {Boolean} [autoResize=true]
* Set to false to prevent polling for viewer size changes. Useful for providing custom resize behavior.
*
* @property {Boolean} [preserveImageSizeOnResize=false]
* Set to true to have the image size preserved when the viewer is resized. This requires autoResize=false.
*
* @property {Number} [pixelsPerWheelLine=40]
* For pixel-resolution scrolling devices, the number of pixels equal to one scroll line.
*
@ -987,6 +990,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
maxZoomPixelRatio: 1.1, //-> higher allows 'over zoom' into pixels
pixelsPerWheelLine: 40,
autoResize: true,
preserveImageSizeOnResize: false, // requires autoResize=false
//DEFAULT CONTROL SETTINGS
showSequenceControl: true, //SEQUENCE

View File

@ -408,6 +408,7 @@ $.Viewer = function( options ) {
width: this.navigatorWidth,
height: this.navigatorHeight,
autoResize: this.navigatorAutoResize,
preserveImageSizeOnResize: this.preserveImageSizeOnResize,
prefixUrl: this.prefixUrl,
viewer: this,
navigatorRotate: this.navigatorRotate,
@ -2836,7 +2837,7 @@ function updateOnce( viewer ) {
THIS[ viewer.hash ].forceRedraw = true;
}
}
else {
else if ( viewer.preserveImageSizeOnResize ) {
containerSize = _getSafeElemSize( viewer.container );
if ( !containerSize.equals( THIS[ viewer.hash ].prevContainerSize ) ) {
var prevContainerSize = THIS[ viewer.hash ].prevContainerSize;
@ -2851,7 +2852,7 @@ function updateOnce( viewer ) {
bounds.height += viewportDiff.y;
bounds.x -= (viewportDiff.x / 2);
bounds.y -= (viewportDiff.y / 2);
viewer.viewport.fitBounds(bounds, true);
viewer.viewport.fitBoundsWithConstraints(bounds, true);
viewer.forceRedraw();
THIS[ viewer.hash ].prevContainerSize = containerSize;