Skip to content

animate

为元素添加动画和过渡效果。

示例

简单动画

可以通过以下方式实现动画,了解 move()scaleOf()rotateOf()

ts
import { Leafer, Rect, PointerEvent, RenderEvent } from 'leafer-ui'

const leafer = new Leafer({ view: window })
const rect = Rect.one({ fill: '#32cd79' }, 0, 30)
leafer.add(rect)

const event = leafer.on_(RenderEvent.NEXT, () => {
    rect.rotateOf('center', 5)
    rect.move(5, 0)
    if (rect.x > 700) rect.x = 0
})

rect.on(PointerEvent.DOWN, () => {
    leafer.off_(event)
})

AnimateEvent.FRAME 会在每一帧的最佳时机触发。

Released under the MIT License.