scrollThreshold
指定可拖动元素必须超出区域边界的像素数量,容器才会开始自动滚动。
接受
- A
Number - A
Functionthat returns aNumber
当使用 Function 定义时,每次容器或目标元素大小调整时,值会自动刷新。
它也可以通过 refresh() 方法手动刷新。
默认
20
scrollThreshold 代码示例
import { createDraggable } from 'animejs';
createDraggable('.square', {
container: '.scroll-container',
scrollThreshold: 12,
});
<div class="scroll-container scroll-x scroll-y">
<div class="scroll-content">
<div class="large padded grid square-grid">
<div class="square draggable"></div>
</div>
</div>
</div>
#draggable-draggable-settings-scrollthreshold .draggable {
background-color: rgba(var(--rgb-current), .25);
border: solid 1px currentColor;
}
#draggable-draggable-settings-scrollthreshold .draggable::after {
content: "";
display: block;
position: absolute;
top: 12px;
left: 12px;
right: 12px;
bottom: 12px;
background-color: currentColor;
border-radius: 2px;
}