@visactor/vrender-components
Version:
components library for dp visualization
78 lines (71 loc) • 3.09 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.registerAxisAnimate = exports.AxisUpdate = exports.AxisEnter = void 0;
const component_1 = require("@visactor/vrender-animate/component"), custom_animate_1 = require("@visactor/vrender-animate/custom/custom-animate"), animate_executor_1 = require("@visactor/vrender-animate/executor/animate-executor"), static_truth_1 = require("./static-truth");
class AxisEnter extends custom_animate_1.AComponentAnimate {
onBind() {
var _a;
const animator = (0, component_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;
(0, static_truth_1.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);
}
}
exports.AxisEnter = AxisEnter;
class AxisUpdate extends custom_animate_1.AComponentAnimate {
onBind() {
const animator = (0, component_1.createComponentAnimator)(this.target);
this._animator = animator;
const duration = this.duration, easing = this.easing, {diffAttrs: diffAttrs} = this.params;
(0, static_truth_1.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() {}
}
function registerAxisAnimate() {
animate_executor_1.AnimateExecutor.registerBuiltInAnimate("axisEnter", AxisEnter),
animate_executor_1.AnimateExecutor.registerBuiltInAnimate("axisUpdate", AxisUpdate);
}
exports.AxisUpdate = AxisUpdate, exports.registerAxisAnimate = registerAxisAnimate;
//# sourceMappingURL=axis-animate.js.map