拖动阈值

指定触发拖拽所需的像素距离。
阈值可以通过使用对象为鼠标或触摸设备分别指定。

dragThreshold: 3,

// Or

dragThreshold: { mouse: 3, touch: 7 },

接受

  • 数字
  • { mouse: 数字, touch: 数字 }
  • 一个 Function,返回一个 Number{ mouse: 数字, touch: 数字 }

当使用 Function 定义时,每当容器或目标元素尺寸改变时,该值将自动刷新。
它也可以通过使用 refresh() 方法手动刷新。

默认值

{ mouse: 3, touch: 7 }

dragThreshold 代码示例

import { createDraggable } from 'animejs';

createDraggable('.square', {
  container: '.grid',
  dragThreshold: 20,
});

createDraggable('.circle', {
  container: '.grid',
  dragThreshold: { mouse: 10, touch: 15 },
});
<div class="large centered grid square-grid">
  <div class="square draggable"></div>
  <div class="circle draggable"></div>
</div>