弹性-Spring
弹性动画受质量mass
阻尼damping
刚度stiffness
影响
它比物理效果里面的弹性提供了更平滑的运动和多样的效果
引入
import { spring } from 'popmotion';
使用
spring({ from: 0, to: 100 })
.start(v => console.log(v))
从from
到to
的一个弹性动画
值的类型
数字、带单位的数字、颜色、复杂的情况、对象、数组
属性
from
默认:0
初始值
to
默认:0
目标值
stiffness
默认:100
刚度,数值越大,越Q弹
damping
默认:10
阻尼,数值越大,挺的越快
mass
默认:1
质量,质量越大,回弹的距离越大
velocity
默认:0
初始化速度,速度越大,物体跑的越快
restDelta
默认:0.01
当数值小于restDelta
并且速度velocity
小于restDelta
时,动画立即停止,数值直接变成to
restDelta
默认:0.01
当数值小于restDelta
并且速度velocity
小于restDelta
时,动画立即停止,数值直接变成to
方法
start
filter
pipe
while
实例方法
stop