You can set animationTime and/or springStiffness when you create the OSD viewer. But this will effect the user experience when manually panning and zooming with mouse (or touchpad/screen etc) too. When I slowed it down as much as I wanted, the manual pan/zoom experience was disconcerting and difficult.
But I worked out this hack to temporarily change the animationTime (or possibly springStiffness too) when doing a #fitBounds, then putting it back to what it was when you are done.
// temporarily set OpenSeadragon animation params
// to a very slow animate, then restore.
function withSlowOSDAnimation(viewport, f) {
// save old ones
var oldValues = {};
oldValues.centerSpringXAnimationTime = viewport.centerSpringX.animationTime;
oldValues.centerSpringYAnimationTime = viewport.centerSpringY.animationTime;
oldValues.zoomSpringAnimationTime = viewport.zoomSpring.animationTime;
// set our new ones
viewport.centerSpringX.animationTime =
viewport.centerSpringY.animationTime =
viewport.zoomSpring.animationTime =
6;
// callback
f()
// restore values
viewport.centerSpringX.animationTime = oldValues.centerSpringXAnimationTime;
viewport.centerSpringY.animationTime = oldValues.centerSpringYAnimationTime;
viewport.zoomSpring.animationTime = oldValues.zoomSpringAnimationTime;
}
Use like:
withSlowOSDAnimation(viewer.viewport, function() {
// stuff
viewer.viewport.fitBounds(somebounds);
});
This works, although I'm not sure if I'm using internal API that may be subject to change. This would perhaps be a good additional feature for OpenSeadragon, ability to supply animationTime, springStiffness, and/or just some OpenSeadragon.Spring object(s) with the fitBounds
call, to apply to that fitBounds
.