@visactor/vrender-components
Version:
components library for dp visualization
72 lines (66 loc) • 2.71 kB
JavaScript
import { createComponentAnimator } from "@visactor/vrender-animate/component";
import { AComponentAnimate } from "@visactor/vrender-animate/custom/custom-animate";
import { AnimateExecutor } from "@visactor/vrender-animate/executor/animate-executor";
import { commitUpdateAnimationTarget } from "./static-truth";
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;
commitUpdateAnimationTarget(this.target, {
x: newX,
y: newY
}, {
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, {diffAttrs: diffAttrs} = this.params;
commitUpdateAnimationTarget(this.target, Object.assign({}, diffAttrs)), animator.animate(this.target, {
type: "to",
to: Object.assign({}, diffAttrs),
duration: duration,
easing: easing,
customParameters: {
diffAttrs: Object.assign({}, diffAttrs)
}
}), this.completeBind(animator);
}
deleteSelfAttr(key) {
this.deleteSelfAttrs([ key ]);
}
deleteSelfAttrs(keys) {
super.deleteSelfAttrs(keys), this._animator.deleteSelfAttrs(keys);
}
tryPreventConflict() {}
}
export function registerAxisAnimate() {
AnimateExecutor.registerBuiltInAnimate("axisEnter", AxisEnter), AnimateExecutor.registerBuiltInAnimate("axisUpdate", AxisUpdate);
}
//# sourceMappingURL=axis-animate.js.map