如何在panzoom中启用平移滚动

问题描述 投票:0回答:1

我正在尝试在应用程序中使用基于vue-panzoom的插件panzoom

问题:我试图在鼠标滚轮(滚动)上启用平移,基本上是在触控板上,我试图平移组件。我能够禁用默认缩放,但无法弄清楚如何在滚动上启用平移

我相信它类似于此https://github.com/anvaka/panzoom/issues/160

这是我到目前为止尝试过的

CodeSandbox:https://codesandbox.io/s/poc-zoompan-2we0v?file=/src/App.vue:717-745任何建议都会有帮助

javascript scroll pan panzoom
1个回答
0
投票

回答我自己的问题。

我能够通过wheel事件实现这一目标。[which is also mentioned here

 window.addEventListener("wheel", e => {
      const transforms = this.$refs.panZoom.$panZoomInstance.getTransform();
      this.$refs.panZoom.$panZoomInstance.moveTo(
        transforms.x - e.deltaX,
        transforms.y - e.deltaY
      );
    });
© www.soinside.com 2019 - 2024. All rights reserved.