@visactor/vrender-components
Version:
components library for dp visualization
66 lines (60 loc) • 3.19 kB
JavaScript
import { createComponentAnimator } from "@visactor/vrender-animate/component";
import { AComponentAnimate } from "@visactor/vrender-animate/custom/custom-animate";
import { IncreaseCount } from "@visactor/vrender-animate/custom/number";
import { AnimateExecutor } from "@visactor/vrender-animate/executor/animate-executor";
export class LabelUpdate extends AComponentAnimate {
onBind() {
const animator = 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() {}
}
export class LabelEnter extends AComponentAnimate {
onBind() {
const animator = 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() {}
}
export function registerLabelAnimate() {
AnimateExecutor.registerBuiltInAnimate("increaseCount", IncreaseCount), AnimateExecutor.registerBuiltInAnimate("labelUpdate", LabelUpdate),
AnimateExecutor.registerBuiltInAnimate("labelEnter", LabelEnter);
}
//# sourceMappingURL=label-animate.js.map