@visactor/vrender-components
Version:
components library for dp visualization
71 lines (64 loc) • 3.57 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.registerLabelAnimate = exports.LabelEnter = exports.LabelUpdate = void 0;
const component_1 = require("@visactor/vrender-animate/component"), custom_animate_1 = require("@visactor/vrender-animate/custom/custom-animate"), number_1 = require("@visactor/vrender-animate/custom/number"), animate_executor_1 = require("@visactor/vrender-animate/executor/animate-executor");
class LabelUpdate extends custom_animate_1.AComponentAnimate {
onBind() {
const animator = (0, component_1.createComponentAnimator)(this.target);
this._animator = animator;
const duration = this.duration, easing = this.easing, {prevText: prevText, curText: curText, prevLabelLine: prevLabelLine, curLabelLine: curLabelLine, increaseEffect: increaseEffect = !0} = this.params, diff = {};
for (const key in curText.attribute) prevText.attribute[key] !== curText.attribute[key] && (diff[key] = curText.attribute[key]);
const rest = Object.assign({}, diff);
delete rest.text, animator.animate(prevText, {
type: "to",
to: rest,
duration: duration,
easing: easing
}), !1 !== increaseEffect && animator.animate(prevText, {
type: "increaseCount",
to: {
text: curText.attribute.text
},
duration: duration,
easing: easing
}), prevLabelLine && animator.animate(prevLabelLine, {
type: "to",
to: curLabelLine.attribute,
duration: duration,
easing: easing
}), this.completeBind(animator);
}
tryPreventConflict() {}
}
exports.LabelUpdate = LabelUpdate;
class LabelEnter extends custom_animate_1.AComponentAnimate {
onBind() {
const animator = (0, component_1.createComponentAnimator)(this.target);
this._animator = animator;
const duration = this.duration, easing = this.easing, {relatedGraphic: relatedGraphic, relatedGraphics: relatedGraphics, config: config} = this.params, {mode: mode, type: type = "fadeIn"} = config, target = this.target;
let startTime = 0;
"after" === mode ? relatedGraphic.animates && relatedGraphic.animates.forEach((animate => {
startTime = Math.max(startTime, animate.getStartTime() + animate.getTotalDuration());
})) : "after-all" === mode ? relatedGraphics && relatedGraphics.forEach((graphic => {
graphic.animates && graphic.animates.forEach((animate => {
startTime = Math.max(startTime, animate.getStartTime() + animate.getTotalDuration());
}));
})) : relatedGraphic.animates && relatedGraphic.animates.forEach((animate => {
startTime = Math.max(startTime, animate.getStartTime());
})), animator.animate(target, Object.assign(Object.assign({}, config), {
duration: duration,
easing: easing,
startTime: startTime,
type: type
})), this.completeBind(animator);
}
tryPreventConflict() {}
}
function registerLabelAnimate() {
animate_executor_1.AnimateExecutor.registerBuiltInAnimate("increaseCount", number_1.IncreaseCount),
animate_executor_1.AnimateExecutor.registerBuiltInAnimate("labelUpdate", LabelUpdate),
animate_executor_1.AnimateExecutor.registerBuiltInAnimate("labelEnter", LabelEnter);
}
exports.LabelEnter = LabelEnter, exports.registerLabelAnimate = registerLabelAnimate;
//# sourceMappingURL=label-animate.js.map