我可以放慢opensedragon的平移/缩放动画吗?



opensedragon真棒。

如果我使用Viewport#fitBounds JS方法移动到一个新的矩形,默认参数,它"动画"当前视图和新请求的边界之间的过渡。

有没有办法控制这个动画的速度?我想放慢速度,这样从当前视图移动到请求的边界需要更长的时间,以便更悠闲地游览。

您可以在创建OSD查看器时设置animationTime和/或spring刚度。但这也会影响用户在使用鼠标(或触摸板/屏幕等)手动移动和缩放时的体验。当我尽可能地放慢速度时,手动平移/变焦的体验令人不安和困难。

但是我想出了这个hack暂时改变animationTime(或可能spring刚度太)当做一个#fitBounds,然后把它放回它是什么,当你完成。

// 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;
}
使用

:

withSlowOSDAnimation(viewer.viewport, function() {
  // stuff
  viewer.viewport.fitBounds(somebounds);
});

这可以工作,虽然我不确定我是否使用可能会发生变化的内部API。这可能是openseaddragon的一个很好的附加功能,能够提供animationTime, spring刚度和/或只是一些openseaddragon。调用fitBounds的弹簧对象,以应用于该fitBounds

很高兴你喜欢!

要影响动画速度,在创建查看器时使用spring刚度和animationTime选项。看到:

http://openseadragon.github.io/docs/OpenSeadragon.html选择

最新更新