Added code to handle the case where autoResize=false. In this mode the image size is preserved and the center is maintained.

This may be considered changing the default behavior so I'd welcome a suggestion to add a configuration parameter to help preserve the default behavior.
This commit is contained in:
Grant Echols 2015-06-22 13:26:24 -06:00
parent 470afb1b7f
commit 1c14f5cc94

View File

@ -2835,6 +2835,28 @@ function updateOnce( viewer ) {
THIS[ viewer.hash ].forceRedraw = true;
}
}
else {
var containerSize = _getSafeElemSize( viewer.container );
if ( !containerSize.equals( THIS[ viewer.hash ].prevContainerSize ) ) {
var prevContainerSize = THIS[ viewer.hash ].prevContainerSize;
var bounds = viewer.viewport.getBounds(true);
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.fitBounds(bounds, true);
viewer.forceRedraw();
THIS[ viewer.hash ].prevContainerSize = containerSize;
THIS[ viewer.hash ].forceRedraw = true;
}
}
var viewportChange = viewer.viewport.update();
var animated = viewer.world.update() || viewportChange;