mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-22 05:06:09 +03:00
Merge pull request #666 from fs-webdev/master
Added code to handle the case where autoResize=true. In this mode th…
This commit is contained in:
commit
769221f659
@ -252,6 +252,9 @@
|
|||||||
* @property {Boolean} [autoResize=true]
|
* @property {Boolean} [autoResize=true]
|
||||||
* Set to false 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.
|
||||||
*
|
*
|
||||||
|
* @property {Boolean} [preserveImageSizeOnResize=false]
|
||||||
|
* Set to true to have the image size preserved when the viewer is resized. This requires autoResize=true (default).
|
||||||
|
*
|
||||||
* @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.
|
||||||
*
|
*
|
||||||
@ -987,6 +990,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
|
|||||||
maxZoomPixelRatio: 1.1, //-> higher allows 'over zoom' into pixels
|
maxZoomPixelRatio: 1.1, //-> higher allows 'over zoom' into pixels
|
||||||
pixelsPerWheelLine: 40,
|
pixelsPerWheelLine: 40,
|
||||||
autoResize: true,
|
autoResize: true,
|
||||||
|
preserveImageSizeOnResize: false, // requires autoResize=true
|
||||||
|
|
||||||
//DEFAULT CONTROL SETTINGS
|
//DEFAULT CONTROL SETTINGS
|
||||||
showSequenceControl: true, //SEQUENCE
|
showSequenceControl: true, //SEQUENCE
|
||||||
|
@ -2824,13 +2824,31 @@ function updateOnce( viewer ) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var containerSize;
|
||||||
if ( viewer.autoResize ) {
|
if ( viewer.autoResize ) {
|
||||||
var containerSize = _getSafeElemSize( viewer.container );
|
containerSize = _getSafeElemSize( viewer.container );
|
||||||
if ( !containerSize.equals( THIS[ viewer.hash ].prevContainerSize ) ) {
|
if ( !containerSize.equals( THIS[ viewer.hash ].prevContainerSize ) ) {
|
||||||
// maintain image position
|
if ( viewer.preserveImageSizeOnResize ) {
|
||||||
var oldBounds = viewer.viewport.getBounds();
|
var prevContainerSize = THIS[ viewer.hash ].prevContainerSize;
|
||||||
var oldCenter = viewer.viewport.getCenter();
|
var bounds = viewer.viewport.getBounds(true);
|
||||||
resizeViewportAndRecenter(viewer, containerSize, oldBounds, oldCenter);
|
var deltaX = (containerSize.x - prevContainerSize.x);
|
||||||
|
var deltaY = (containerSize.y - prevContainerSize.y);
|
||||||
|
var viewportDiff = viewer.viewport.deltaPointsFromPixels(new OpenSeadragon.Point(deltaX, deltaY), true);
|
||||||
|
viewer.viewport.resize(new OpenSeadragon.Point(containerSize.x, containerSize.y), false);
|
||||||
|
|
||||||
|
// Keep the center of the image in the center and just adjust the amount of image shown
|
||||||
|
bounds.width += viewportDiff.x;
|
||||||
|
bounds.height += viewportDiff.y;
|
||||||
|
bounds.x -= (viewportDiff.x / 2);
|
||||||
|
bounds.y -= (viewportDiff.y / 2);
|
||||||
|
viewer.viewport.fitBoundsWithConstraints(bounds, true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// 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 ].prevContainerSize = containerSize;
|
||||||
THIS[ viewer.hash ].forceRedraw = true;
|
THIS[ viewer.hash ].forceRedraw = true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user