OpenSeadragon provides several options for constraining the minimum and maximum zoom range as well as the range of panning.
These features are generally controlled through various combinations of the options:
panHorizontal
(default: true)
panVertical
(default: true)
constrainDuringPan
(default: false)
wrapHorizontal
(default: false)
wrapVertical
(default: false)
visibilityRatio
(default: 0.5)
minPixelRatio
(default: 0.5)
minZoomImageRatio
(default: 0.8)
maxZoomPixelRatio
(default: 2)
defaultZoomLevel
(default: 0)
minZoomLevel
(default: null)
maxZoomLevel
(default: null)
The option
visibilityRatio
, which is by default 0.5,
ensures that you cannot pan the image far enough to fill the viewport with
more than 50% background. Setting it to 1, as in this example, ensures
the image cannot be panned to show any background. Normally OpenSeadragon
will enforce this by "bouncing back" when the drag is released. In this
example we also add constrainDuringPan: true
which stops the drag
immediately when it hits the bounding area.
constrainDuringPan
Enabled
Below is the relevant configuration.
OpenSeadragon({ ... visibilityRatio: 1.0, constrainDuringPan: true, ... });
In this example we combine a number of options to produce an effect similar to a "fit-width" PDF view.
Below is the relevant configuration.
OpenSeadragon({ ... panHorizontal: false, defaultZoomLevel: 1, minZoomLevel: 1, maxZoomLevel: 1, visibilityRatio: 1, ... });