UNPKG

@visactor/vrender-animate

Version:

This module provides a graph-based animation system for VRender.

23 lines (22 loc) 1.11 kB
import { ACustomAnimate } from "./custom-animate"; export class MotionPath extends ACustomAnimate { constructor(from, to, duration, easing, params) { var _a; super(from, to, duration, easing, params), params && (this.pathLength = params.path.getLength(), this.path = params.path, this.distance = params.distance, this.totalLength = this.distance * this.pathLength, this.initAngle = null !== (_a = params.initAngle) && void 0 !== _a ? _a : 0, this.changeAngle = !!params.changeAngle, this.cb = params.cb); } onBind() { this.from = { x: 0, y: 0 }, this.to = this.path.getAttrAt(this.totalLength).pos, this.props = this.to; } onUpdate(end, ratio, out) { const attrs = {}, at = this.totalLength * ratio, {pos: pos, angle: angle} = this.path.getAttrAt(at); attrs.x = pos.x, attrs.y = pos.y, this.changeAngle && (attrs.angle = angle + this.initAngle), this.cb && this.cb(this.from, this.to, ratio, this.target), this.target.setAttributes(attrs); } } //# sourceMappingURL=motionPath.js.map