mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-22 05:06:09 +03:00
Merge pull request #291 from msalsbery/preserve-zoom-on-resize
Added autoResize option
This commit is contained in:
commit
c11098326a
@ -57,7 +57,8 @@ OPENSEADRAGON CHANGELOG
|
|||||||
* Viewer.innerTracker.scrollHandler: preventDefaultAction == true prevents viewer zooming on mousewheel/pinch
|
* Viewer.innerTracker.scrollHandler: preventDefaultAction == true prevents viewer zooming on mousewheel/pinch
|
||||||
* Fixed: IE8 error with custom buttons - "Object doesn't support this action" (#279)
|
* Fixed: IE8 error with custom buttons - "Object doesn't support this action" (#279)
|
||||||
* Support IIIF servers that don't report tile dimensions (#286)
|
* Support IIIF servers that don't report tile dimensions (#286)
|
||||||
* Added a static 'version' property to OpenSeadragon. Useful for plugins that require specific OpenSeadragon versions.
|
* Added an autoResize option. Default is true. When set to false, the viewer takes no action when its container element is resized. (#291)
|
||||||
|
* Added a static 'version' property to OpenSeadragon. Useful for plugins that require specific OpenSeadragon versions. (#292)
|
||||||
|
|
||||||
0.9.131:
|
0.9.131:
|
||||||
|
|
||||||
|
@ -224,6 +224,9 @@
|
|||||||
* image though it is less effective visually if the HTML5 Canvas is not
|
* image though it is less effective visually if the HTML5 Canvas is not
|
||||||
* availble on the viewing device.
|
* availble on the viewing device.
|
||||||
*
|
*
|
||||||
|
* @property {Boolean} [autoResize=true]
|
||||||
|
* Set to false to prevent polling for viewer size changes. Useful for providing custom resize behavior.
|
||||||
|
*
|
||||||
* @property {Number} [pixelsPerWheelLine=40]
|
* @property {Number} [pixelsPerWheelLine=40]
|
||||||
* For pixel-resolution scrolling devices, the number of pixels equal to one scroll line.
|
* For pixel-resolution scrolling devices, the number of pixels equal to one scroll line.
|
||||||
*
|
*
|
||||||
@ -691,6 +694,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
|
|||||||
minZoomImageRatio: 0.9, //-> closer to 0 allows zoom out to infinity
|
minZoomImageRatio: 0.9, //-> closer to 0 allows zoom out to infinity
|
||||||
maxZoomPixelRatio: 1.1, //-> higher allows 'over zoom' into pixels
|
maxZoomPixelRatio: 1.1, //-> higher allows 'over zoom' into pixels
|
||||||
pixelsPerWheelLine: 40,
|
pixelsPerWheelLine: 40,
|
||||||
|
autoResize: true,
|
||||||
|
|
||||||
//DEFAULT CONTROL SETTINGS
|
//DEFAULT CONTROL SETTINGS
|
||||||
showSequenceControl: true, //SEQUENCE
|
showSequenceControl: true, //SEQUENCE
|
||||||
|
@ -1896,14 +1896,16 @@ function updateOnce( viewer ) {
|
|||||||
|
|
||||||
//viewer.profiler.beginUpdate();
|
//viewer.profiler.beginUpdate();
|
||||||
|
|
||||||
containerSize = _getSafeElemSize( viewer.container );
|
if ( viewer.autoResize ) {
|
||||||
if ( !containerSize.equals( THIS[ viewer.hash ].prevContainerSize ) ) {
|
containerSize = _getSafeElemSize( viewer.container );
|
||||||
// maintain image position
|
if ( !containerSize.equals( THIS[ viewer.hash ].prevContainerSize ) ) {
|
||||||
var oldBounds = viewer.viewport.getBounds();
|
// maintain image position
|
||||||
var oldCenter = viewer.viewport.getCenter();
|
var oldBounds = viewer.viewport.getBounds();
|
||||||
resizeViewportAndRecenter(viewer, containerSize, oldBounds, oldCenter);
|
var oldCenter = viewer.viewport.getCenter();
|
||||||
THIS[ viewer.hash ].prevContainerSize = containerSize;
|
resizeViewportAndRecenter(viewer, containerSize, oldBounds, oldCenter);
|
||||||
THIS[ viewer.hash ].forceRedraw = true;
|
THIS[ viewer.hash ].prevContainerSize = containerSize;
|
||||||
|
THIS[ viewer.hash ].forceRedraw = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
animated = viewer.viewport.update();
|
animated = viewer.viewport.update();
|
||||||
|
@ -674,14 +674,15 @@ $.Viewport.prototype = /** @lends OpenSeadragon.Viewport.prototype */{
|
|||||||
resize: function( newContainerSize, maintain ) {
|
resize: function( newContainerSize, maintain ) {
|
||||||
var oldBounds = this.getBounds(),
|
var oldBounds = this.getBounds(),
|
||||||
newBounds = oldBounds,
|
newBounds = oldBounds,
|
||||||
widthDeltaFactor = newContainerSize.x / this.containerSize.x;
|
widthDeltaFactor;
|
||||||
|
|
||||||
this.containerSize = new $.Point(
|
this.containerSize = new $.Point(
|
||||||
newContainerSize.x,
|
newContainerSize.x,
|
||||||
newContainerSize.y
|
newContainerSize.y
|
||||||
);
|
);
|
||||||
|
|
||||||
if (maintain) {
|
if ( maintain ) {
|
||||||
|
widthDeltaFactor = newContainerSize.x / this.containerSize.x;
|
||||||
newBounds.width = oldBounds.width * widthDeltaFactor;
|
newBounds.width = oldBounds.width * widthDeltaFactor;
|
||||||
newBounds.height = newBounds.width / this.getAspectRatio();
|
newBounds.height = newBounds.width / this.getAspectRatio();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user