UNPKG

@visactor/vrender-components

Version:

components library for dp visualization

60 lines (57 loc) 2.29 kB
import { AComponentAnimate, AnimateExecutor, createComponentAnimator } from "@visactor/vrender-animate"; export class AxisEnter extends AComponentAnimate { onBind() { var _a; const animator = createComponentAnimator(this.target); this._animator = animator; const duration = this.duration, easing = this.easing, {config: config, lastScale: lastScale, getTickCoord: getTickCoord} = this.params; let ratio = 1; const currData = this.target.data; if (lastScale && getTickCoord && currData) { ratio = .7; const point = getTickCoord(lastScale.scale(currData.rawValue)), newX = this.target.attribute.x, newY = this.target.attribute.y; this.target.setAttributes({ x: point.x, y: point.y }), animator.animate(this.target, { type: "to", to: { x: newX, y: newY }, duration: duration, easing: easing }); } animator.animate(this.target, { type: null !== (_a = config.type) && void 0 !== _a ? _a : "fadeIn", to: config.to, duration: duration * ratio, easing: easing }), this.completeBind(animator); } } export class AxisUpdate extends AComponentAnimate { onBind() { const animator = createComponentAnimator(this.target); this._animator = animator; const duration = this.duration, easing = this.easing, {config: config, diffAttrs: diffAttrs} = this.params; animator.animate(this.target, { type: "to", to: Object.assign({}, diffAttrs), duration: duration, easing: easing, customParameters: { diffAttrs: Object.assign({}, diffAttrs) } }), this.completeBind(animator); } deleteSelfAttr(key) { super.deleteSelfAttr(key), this._animator.deleteSelfAttr(key); } tryPreventConflict() {} } export function registerAxisAnimate() { AnimateExecutor.registerBuiltInAnimate("axisEnter", AxisEnter), AnimateExecutor.registerBuiltInAnimate("axisUpdate", AxisUpdate); } //# sourceMappingURL=axis-animate.js.map