运动 / iOS / NATIVESCRIPT VUE
跟随每一刻。
一串弹簧,始终回应你的输入。
动效背后的代码。
Jolt 0.1.0-rc.11直接来自指南的核心 API 示例。完整界面与控件请查看完整演示。
TypeScript · NativeScript
import { bind, motionScope, motionValue, set, springValue } from '@rafaelaugusto/jolt'
const scope = motionScope()
const pointer = motionValue(0)
const first = scope.add(springValue(pointer, { stiffness: 260, damping: 24 }))
const second = scope.add(springValue(first, { stiffness: 260, damping: 24 }))
scope.use(() => bind(cursor, { x: first }))
scope.use(() => bind(trailingCursor, { x: second }))
set(pointer, 180)
set(pointer, -40) // preserves each follower's position and velocity
// On page/component disposal:
scope.dispose()