容器内边距
指定容器的内边距(以像素为单位)。
接受
数字Array<Number>([上, 右, 下, 左])- 一个返回
Array<Number>([上, 右, 下, 左]) 的Function
当使用 Function 定义时,每当容器或目标元素尺寸改变时,该值将自动刷新。
它也可以通过使用 refresh() 方法手动刷新。
默认值
0
containerPadding 代码示例
import { createDraggable } from 'animejs';
createDraggable('.square', {
container: '.grid',
containerPadding: [ 16, 32, -16, 64], // top, right, bottom, left
scrollThreshold: 0,
});
<div class="large centered padded show-bounds grid square-grid">
<div class="square draggable"></div>
</div>
.grid.padded.show-bounds::after {
opacity: 1;
top: calc(1rem);
right: calc(2rem - 1px);
bottom: calc(-1rem - 1px);
left: calc(4rem);
border: 1px dashed currentColor;
box-shadow: none;
}