@visactor/vrender-components
Version:
components library for dp visualization
71 lines (64 loc) • 2.63 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.registerAxisAnimate = exports.AxisUpdate = exports.AxisEnter = void 0;
const vrender_animate_1 = require("@visactor/vrender-animate");
class AxisEnter extends vrender_animate_1.AComponentAnimate {
onBind() {
var _a;
const animator = (0, vrender_animate_1.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);
}
}
exports.AxisEnter = AxisEnter;
class AxisUpdate extends vrender_animate_1.AComponentAnimate {
onBind() {
const animator = (0, vrender_animate_1.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() {}
}
function registerAxisAnimate() {
vrender_animate_1.AnimateExecutor.registerBuiltInAnimate("axisEnter", AxisEnter),
vrender_animate_1.AnimateExecutor.registerBuiltInAnimate("axisUpdate", AxisUpdate);
}
exports.AxisUpdate = AxisUpdate, exports.registerAxisAnimate = registerAxisAnimate;
//# sourceMappingURL=axis-animate.js.map