簡體   English   中英

如何使 vis-timeline pan-x 平滑和輕松?

[英]How to Make the vis-timeline pan-x smooth and eased?

我正在使用 vis-timeline 庫。 在文檔中,沒有用於在導航時間軸時緩和觸摸 pan-x 的屬性,從而導致僵硬和死板的導航。

我試過這個:

timeline.on('rangechange', function(properties) {

  var windowStart = timeline.getWindow().start;
  var windowEnd = timeline.getWindow().end;

  var distance = properties.event.deltaX * properties.event.velocityX;

  var newWindowStart = windowStart.valueOf() - distance;
  var newWindowEnd = windowEnd.valueOf() - distance;

  timeline.setWindow(newWindowStart, newWindowEnd, {
    animation: {
      easingFunction: 'easeInOutQuad'
    }
  });
});

我如何實現輕松的 panX 導航?

好的,我找到了解決方案。

這是我的代碼:

    timeline.on("rangechanged", (properties) => {
      if (properties.event) {
        let distance =
          properties.event.deltaX *
          Math.abs(properties.event.velocityX);

        let newWindowStart = new Date(
          properties.start.valueOf() - distance * 100000000
        );
        let newWindowEnd = new Date(
          properties.end.valueOf() - distance * 100000000
        );

        timeline.setWindow(
          newWindowStart,
          newWindowEnd,
          {
            animation: {
              duration: 500,
              easingFunction: "easeOutQuad",
            },
          }
        );
      }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM