mirror of
https://github.com/openseadragon/openseadragon.git
synced 2025-02-16 14:53:14 +03:00
Added option to avoid image from snapping to home bounds on resize.
This commit is contained in:
parent
5a2733bbc1
commit
bd4921c285
@ -255,6 +255,11 @@
|
||||
* @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.
|
||||
*
|
||||
@ -995,6 +1000,7 @@ 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
|
||||
|
@ -2947,11 +2947,18 @@ function resizeViewportAndRecenter( viewer, containerSize, oldBounds, oldCenter
|
||||
|
||||
viewport.resize( containerSize, true );
|
||||
|
||||
// We try to remove blanks as much as possible
|
||||
var worldBounds = viewer.world.getHomeBounds();
|
||||
var newWidth = oldBounds.width <= worldBounds.width ? oldBounds.width : worldBounds.width;
|
||||
var newHeight = oldBounds.height <= worldBounds.height ?
|
||||
oldBounds.height : worldBounds.height;
|
||||
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 ),
|
||||
@ -2959,7 +2966,12 @@ function resizeViewportAndRecenter( viewer, containerSize, oldBounds, oldCenter
|
||||
newWidth,
|
||||
newHeight
|
||||
);
|
||||
viewport.fitBounds( newBounds, true );
|
||||
|
||||
if (viewer.allowZoomToConstraintsOnResize) {
|
||||
viewport.fitBoundsWithConstraints( newBounds, true );
|
||||
} else {
|
||||
viewport.fitBounds( newBounds, true );
|
||||
}
|
||||
}
|
||||
|
||||
function drawWorld( viewer ) {
|
||||
|
@ -5,11 +5,20 @@
|
||||
<script type="text/javascript" src='../../build/openseadragon/openseadragon.js'></script>
|
||||
<script type="text/javascript" src='../lib/jquery-1.9.1.min.js'></script>
|
||||
<style type="text/css">
|
||||
|
||||
.openseadragon1 {
|
||||
width: 800px;
|
||||
height: 600px;
|
||||
}
|
||||
|
||||
html, body {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.openseadragon1 {
|
||||
width: 80%;
|
||||
height: 80%;
|
||||
background-color: white;
|
||||
border: 10px solid black;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
@ -21,11 +30,12 @@
|
||||
<script type="text/javascript">
|
||||
|
||||
var viewer = OpenSeadragon({
|
||||
// debugMode: true,
|
||||
debugMode: true,
|
||||
id: "contentDiv",
|
||||
prefixUrl: "../../build/openseadragon/images/",
|
||||
tileSources: "../data/testpattern.dzi",
|
||||
showNavigator:true
|
||||
minZoomImageRatio: 0.8,
|
||||
allowZoomToConstraintsOnResize: true
|
||||
});
|
||||
|
||||
</script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user