@visactor/vrender-components 0.23.0-alpha.3 → 1.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/animation/animate-component.d.ts +22 -0
- package/cjs/animation/animate-component.js +29 -0
- package/cjs/animation/animate-component.js.map +1 -0
- package/cjs/animation/axis-animate.d.ts +10 -0
- package/cjs/animation/axis-animate.js +71 -0
- package/cjs/animation/axis-animate.js.map +1 -0
- package/cjs/animation/label-animate.d.ts +10 -0
- package/cjs/animation/label-animate.js +80 -0
- package/cjs/animation/label-animate.js.map +1 -0
- package/cjs/axis/animate/config.d.ts +6 -0
- package/cjs/axis/animate/config.js +10 -0
- package/cjs/axis/animate/config.js.map +1 -0
- package/cjs/axis/animate/group-transition.d.ts +2 -1
- package/cjs/axis/animate/group-transition.js +2 -2
- package/cjs/axis/animate/group-transition.js.map +1 -1
- package/cjs/axis/base.d.ts +7 -2
- package/cjs/axis/base.js +70 -5
- package/cjs/axis/base.js.map +1 -1
- package/cjs/axis/line.js.map +1 -1
- package/cjs/axis/register.js +2 -2
- package/cjs/axis/register.js.map +1 -1
- package/cjs/axis/type.d.ts +4 -0
- package/cjs/axis/type.js.map +1 -1
- package/cjs/brush/config.js +1 -2
- package/cjs/brush/type.js +2 -1
- package/cjs/crosshair/rect.js +1 -2
- package/cjs/crosshair/type.js +2 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/indicator/register.js +1 -2
- package/cjs/jsx/index.js +2 -1
- package/cjs/label/animate/animate.d.ts +1 -12
- package/cjs/label/animate/animate.js +1 -78
- package/cjs/label/animate/animate.js.map +1 -1
- package/cjs/label/base.d.ts +4 -3
- package/cjs/label/base.js +40 -32
- package/cjs/label/base.js.map +1 -1
- package/cjs/label/dataLabel.js +1 -1
- package/cjs/label/overlap/scaler.js +3 -3
- package/cjs/label/overlap/scaler.js.map +1 -1
- package/cjs/label/register.d.ts +1 -0
- package/cjs/label/register.js +8 -4
- package/cjs/label/register.js.map +1 -1
- package/cjs/label-item/index.js +1 -1
- package/cjs/label-item/label-item.js +1 -1
- package/cjs/label-item/label-item.js.map +1 -1
- package/cjs/label-item/register.js +1 -1
- package/cjs/label-item/type.js +1 -1
- package/cjs/poptip/contribution.js +4 -2
- package/cjs/poptip/contribution.js.map +1 -1
- package/cjs/poptip/poptip.d.ts +5 -0
- package/cjs/poptip/poptip.js +87 -18
- package/cjs/poptip/poptip.js.map +1 -1
- package/cjs/poptip/type.d.ts +4 -1
- package/cjs/poptip/type.js.map +1 -1
- package/cjs/tag/tag.js +60 -56
- package/cjs/tag/tag.js.map +1 -1
- package/cjs/weather/weather-box.d.ts +1 -2
- package/cjs/weather/weather-box.js.map +1 -1
- package/dist/index.es.js +2398 -1787
- package/es/animation/animate-component.d.ts +22 -0
- package/es/animation/animate-component.js +21 -0
- package/es/animation/animate-component.js.map +1 -0
- package/es/animation/axis-animate.d.ts +10 -0
- package/es/animation/axis-animate.js +60 -0
- package/es/animation/axis-animate.js.map +1 -0
- package/es/animation/label-animate.d.ts +10 -0
- package/es/animation/label-animate.js +69 -0
- package/es/animation/label-animate.js.map +1 -0
- package/es/axis/animate/config.d.ts +6 -0
- package/es/axis/animate/config.js +6 -0
- package/es/axis/animate/config.js.map +1 -0
- package/es/axis/animate/group-transition.d.ts +2 -1
- package/es/axis/animate/group-transition.js +3 -1
- package/es/axis/animate/group-transition.js.map +1 -1
- package/es/axis/base.d.ts +7 -2
- package/es/axis/base.js +75 -9
- package/es/axis/base.js.map +1 -1
- package/es/axis/line.js.map +1 -1
- package/es/axis/register.js +3 -1
- package/es/axis/register.js.map +1 -1
- package/es/axis/type.d.ts +4 -0
- package/es/axis/type.js.map +1 -1
- package/es/brush/config.js +1 -2
- package/es/brush/type.js +2 -1
- package/es/crosshair/rect.js +1 -2
- package/es/crosshair/type.js +2 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/indicator/register.js +1 -2
- package/es/jsx/index.js +2 -1
- package/es/label/animate/animate.d.ts +1 -12
- package/es/label/animate/animate.js +0 -76
- package/es/label/animate/animate.js.map +1 -1
- package/es/label/base.d.ts +4 -3
- package/es/label/base.js +42 -32
- package/es/label/base.js.map +1 -1
- package/es/label/dataLabel.js +1 -1
- package/es/label/overlap/scaler.js +1 -1
- package/es/label/overlap/scaler.js.map +1 -1
- package/es/label/register.d.ts +1 -0
- package/es/label/register.js +7 -1
- package/es/label/register.js.map +1 -1
- package/es/label-item/index.js +1 -1
- package/es/label-item/label-item.js +1 -1
- package/es/label-item/label-item.js.map +1 -1
- package/es/label-item/register.js +1 -1
- package/es/label-item/type.js +1 -1
- package/es/poptip/contribution.js +4 -2
- package/es/poptip/contribution.js.map +1 -1
- package/es/poptip/poptip.d.ts +5 -0
- package/es/poptip/poptip.js +85 -19
- package/es/poptip/poptip.js.map +1 -1
- package/es/poptip/type.d.ts +4 -1
- package/es/poptip/type.js.map +1 -1
- package/es/tag/tag.js +59 -56
- package/es/tag/tag.js.map +1 -1
- package/es/weather/weather-box.d.ts +1 -2
- package/es/weather/weather-box.js.map +1 -1
- package/package.json +7 -7
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { EasingType } from '@visactor/vrender-core';
|
|
2
|
+
import { AbstractComponent } from '../core/base';
|
|
3
|
+
interface AnimateComponentAttribute {
|
|
4
|
+
animation?: boolean | any;
|
|
5
|
+
animationEnter?: boolean | any;
|
|
6
|
+
animationExit?: boolean | any;
|
|
7
|
+
animationUpdate?: boolean | any;
|
|
8
|
+
}
|
|
9
|
+
export interface ICommonAnimation {
|
|
10
|
+
duration?: number;
|
|
11
|
+
delay?: number;
|
|
12
|
+
easing?: EasingType;
|
|
13
|
+
}
|
|
14
|
+
export declare abstract class AnimateComponent<T extends AnimateComponentAttribute> extends AbstractComponent<T> {
|
|
15
|
+
protected _animationConfig?: {
|
|
16
|
+
enter: ICommonAnimation | false;
|
|
17
|
+
exit: ICommonAnimation | false;
|
|
18
|
+
update: ICommonAnimation | false;
|
|
19
|
+
};
|
|
20
|
+
_prepareAnimate(defaultAnimation: ICommonAnimation): void;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: !0
|
|
5
|
+
}), exports.AnimateComponent = void 0;
|
|
6
|
+
|
|
7
|
+
const base_1 = require("../core/base"), vutils_1 = require("@visactor/vutils");
|
|
8
|
+
|
|
9
|
+
class AnimateComponent extends base_1.AbstractComponent {
|
|
10
|
+
_prepareAnimate(defaultAnimation) {
|
|
11
|
+
if (!1 !== this.attribute.animation) {
|
|
12
|
+
const {animation: animation, animationEnter: animationEnter, animationExit: animationExit, animationUpdate: animationUpdate} = this.attribute, animationCfg = (0,
|
|
13
|
+
vutils_1.isObject)(animation) ? animation : {};
|
|
14
|
+
this._animationConfig = {
|
|
15
|
+
enter: !1 !== animationEnter && (0, vutils_1.merge)({}, defaultAnimation, animationCfg, null != animationEnter ? animationEnter : {}),
|
|
16
|
+
exit: !1 !== animationExit && (0, vutils_1.merge)({}, defaultAnimation, animationCfg, null != animationExit ? animationExit : {}),
|
|
17
|
+
update: !1 !== animationUpdate && ((0, vutils_1.isArray)(animationUpdate) ? animationUpdate : (0,
|
|
18
|
+
vutils_1.merge)({}, defaultAnimation, animationCfg, null != animationUpdate ? animationUpdate : {}))
|
|
19
|
+
};
|
|
20
|
+
} else this._animationConfig = {
|
|
21
|
+
enter: !1,
|
|
22
|
+
exit: !1,
|
|
23
|
+
update: !1
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
exports.AnimateComponent = AnimateComponent;
|
|
29
|
+
//# sourceMappingURL=animate-component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/animation/animate-component.ts"],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cesContent":["import type { EasingType } from '@visactor/vrender-core';\nimport { AbstractComponent } from '../core/base';\nimport { isArray, isObject, merge } from '@visactor/vutils';\n\ninterface AnimateComponentAttribute {\n animation?: boolean | any;\n animationEnter?: boolean | any;\n animationExit?: boolean | any;\n animationUpdate?: boolean | any;\n}\n\n/**\n * 标签的离场动画配置\n */\nexport interface ICommonAnimation {\n /**\n * 动画执行的时长\n */\n duration?: number;\n /**\n * 动画延迟的时长\n */\n delay?: number;\n /**\n * 动画的缓动函数\n */\n easing?: EasingType;\n}\n\nexport abstract class AnimateComponent<T extends AnimateComponentAttribute> extends AbstractComponent<T> {\n // parsed animation config\n protected _animationConfig?: {\n enter: ICommonAnimation | false;\n exit: ICommonAnimation | false;\n update: ICommonAnimation | false;\n };\n\n _prepareAnimate(defaultAnimation: ICommonAnimation) {\n if (this.attribute.animation !== false) {\n const { animation, animationEnter, animationExit, animationUpdate } = this.attribute;\n const animationCfg = isObject(animation) ? animation : {};\n this._animationConfig = {\n enter: animationEnter !== false ? merge({}, defaultAnimation, animationCfg, animationEnter ?? {}) : false,\n exit: animationExit !== false ? merge({}, defaultAnimation, animationCfg, animationExit ?? {}) : false,\n update:\n animationUpdate !== false\n ? isArray(animationUpdate)\n ? animationUpdate\n : merge({}, defaultAnimation, animationCfg, animationUpdate ?? {})\n : false\n };\n } else {\n this._animationConfig = {\n enter: false,\n exit: false,\n update: false\n };\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AComponentAnimate } from '@visactor/vrender-animate';
|
|
2
|
+
export declare class AxisEnter extends AComponentAnimate<any> {
|
|
3
|
+
onBind(): void;
|
|
4
|
+
}
|
|
5
|
+
export declare class AxisUpdate extends AComponentAnimate<any> {
|
|
6
|
+
onBind(): void;
|
|
7
|
+
deleteSelfAttr(key: string): void;
|
|
8
|
+
protected tryPreventConflict(): void;
|
|
9
|
+
}
|
|
10
|
+
export declare function registerAxisAnimate(): void;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: !0
|
|
5
|
+
}), exports.registerAxisAnimate = exports.AxisUpdate = exports.AxisEnter = void 0;
|
|
6
|
+
|
|
7
|
+
const vrender_animate_1 = require("@visactor/vrender-animate");
|
|
8
|
+
|
|
9
|
+
class AxisEnter extends vrender_animate_1.AComponentAnimate {
|
|
10
|
+
onBind() {
|
|
11
|
+
var _a;
|
|
12
|
+
const animator = (0, vrender_animate_1.createComponentAnimator)(this.target);
|
|
13
|
+
this._animator = animator;
|
|
14
|
+
const duration = this.duration, easing = this.easing, {config: config, lastScale: lastScale, getTickCoord: getTickCoord} = this.params;
|
|
15
|
+
let ratio = 1;
|
|
16
|
+
if (lastScale && getTickCoord) {
|
|
17
|
+
ratio = .7;
|
|
18
|
+
const currData = this.target.data, point = getTickCoord(lastScale.scale(currData.rawValue)), newX = this.target.attribute.x, newY = this.target.attribute.y;
|
|
19
|
+
this.target.setAttributes({
|
|
20
|
+
x: point.x,
|
|
21
|
+
y: point.y
|
|
22
|
+
}), animator.animate(this.target, {
|
|
23
|
+
type: "to",
|
|
24
|
+
to: {
|
|
25
|
+
x: newX,
|
|
26
|
+
y: newY
|
|
27
|
+
},
|
|
28
|
+
duration: duration,
|
|
29
|
+
easing: easing
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
animator.animate(this.target, {
|
|
33
|
+
type: null !== (_a = config.type) && void 0 !== _a ? _a : "fadeIn",
|
|
34
|
+
to: config.to,
|
|
35
|
+
duration: duration * ratio,
|
|
36
|
+
easing: easing
|
|
37
|
+
}), this.completeBind(animator);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
exports.AxisEnter = AxisEnter;
|
|
42
|
+
|
|
43
|
+
class AxisUpdate extends vrender_animate_1.AComponentAnimate {
|
|
44
|
+
onBind() {
|
|
45
|
+
var _a;
|
|
46
|
+
const animator = (0, vrender_animate_1.createComponentAnimator)(this.target);
|
|
47
|
+
this._animator = animator;
|
|
48
|
+
const duration = this.duration, easing = this.easing, {config: config, diffAttrs: diffAttrs} = this.params;
|
|
49
|
+
animator.animate(this.target, {
|
|
50
|
+
type: null !== (_a = config.type) && void 0 !== _a ? _a : "to",
|
|
51
|
+
to: Object.assign({}, diffAttrs),
|
|
52
|
+
duration: duration,
|
|
53
|
+
easing: easing,
|
|
54
|
+
customParameters: {
|
|
55
|
+
diffAttrs: Object.assign({}, diffAttrs)
|
|
56
|
+
}
|
|
57
|
+
}), this.completeBind(animator);
|
|
58
|
+
}
|
|
59
|
+
deleteSelfAttr(key) {
|
|
60
|
+
super.deleteSelfAttr(key), this._animator.deleteSelfAttr(key);
|
|
61
|
+
}
|
|
62
|
+
tryPreventConflict() {}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function registerAxisAnimate() {
|
|
66
|
+
vrender_animate_1.AnimateExecutor.registerBuiltInAnimate("axisEnter", AxisEnter),
|
|
67
|
+
vrender_animate_1.AnimateExecutor.registerBuiltInAnimate("axisUpdate", AxisUpdate);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
exports.AxisUpdate = AxisUpdate, exports.registerAxisAnimate = registerAxisAnimate;
|
|
71
|
+
//# sourceMappingURL=axis-animate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/animation/axis-animate.ts"],"names":[],"mappings":";;;AAAA,+DAAwG;AAKxG,MAAa,SAAU,SAAQ,mCAAsB;IACnD,MAAM;;QACJ,MAAM,QAAQ,GAAG,IAAA,yCAAuB,EAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACtD,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC/B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC3B,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,G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;QACtD,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC/B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC3B,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC;QAmB1C,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE;YAC5B,IAAI,EAAE,MAAA,MAAM,CAAC,IAAI,mCAAI,IAAI;YACzB,EAAE,oBAAO,SAAS,CAAE;YACpB,QAAQ;YACR,MAAM;YACN,gBAAgB,EAAE;gBAChB,SAAS,oBAAO,SAAS,CAAE;aAC5B;SACF,CAAC,CAAC;QACH,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC;IAGD,cAAc,CAAC,GAAW;QACxB,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;QAC1B,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;IACrC,CAAC;IAGS,kBAAkB;QAC1B,OAAO;IACT,CAAC;CACF;AA/CD,gCA+CC;AAED,SAAgB,mBAAmB;IAEjC,iCAAe,CAAC,sBAAsB,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IAC/D,iCAAe,CAAC,sBAAsB,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;AACnE,CAAC;AAJD,kDAIC","file":"axis-animate.js","sourcesContent":["import { AComponentAnimate, AnimateExecutor, createComponentAnimator } from '@visactor/vrender-animate';\n\n/**\n * AxisEnter class handles the enter animation for Axis components\n */\nexport class AxisEnter extends AComponentAnimate<any> {\n onBind(): void {\n const animator = createComponentAnimator(this.target);\n this._animator = animator;\n const duration = this.duration;\n const easing = this.easing;\n const { config, lastScale, getTickCoord } = this.params;\n\n let ratio = 1;\n\n if (lastScale && getTickCoord) {\n ratio = 0.7;\n const currData = this.target.data;\n\n const oldValue = lastScale.scale(currData.rawValue);\n const point = getTickCoord(oldValue);\n const newX = this.target.attribute.x;\n const newY = this.target.attribute.y;\n\n this.target.setAttributes({ x: point.x, y: point.y });\n animator.animate(this.target, {\n type: 'to',\n to: { x: newX, y: newY },\n duration,\n easing\n });\n }\n\n // if (updateEls && updateEls.length > 1) {\n // ratio = 0.5;\n // const oldData1 = updateEls[0].oldEl.data;\n // const { rawValue: oldRawValue1, value: oldValue1 } = oldData1;\n // const oldData2 = updateEls[1].oldEl.data;\n // const { rawValue: oldRawValue2, value: oldValue2 } = oldData2;\n // const data = this.target.data;\n // const { rawValue: newRawValue } = data;\n // // rawValue 是原始值,value是映射出来的值,假设是线性映射,计算一下newRawValue在old阶段的value是什么值\n // const oldValue =\n // oldValue1 + ((oldValue2 - oldValue1) * (newRawValue - oldRawValue1)) / (oldRawValue2 - oldRawValue1);\n // // 将 x 和 y 做映射\n // const oldX1 = updateEls[0].oldEl.attribute.x;\n // const oldY1 = updateEls[0].oldEl.attribute.y;\n // const oldX2 = updateEls[1].oldEl.attribute.x;\n // const oldY2 = updateEls[1].oldEl.attribute.y;\n // const oldX = oldX1 + ((oldX2 - oldX1) * (oldValue - oldValue1)) / (oldValue2 - oldValue1);\n // const oldY = oldY1 + ((oldY2 - oldY1) * (oldValue - oldValue1)) / (oldValue2 - oldValue1);\n // const newX = this.target.attribute.x;\n // const newY = this.target.attribute.y;\n\n // this.target.setAttributes({ x: oldX, y: oldY });\n // animator.animate(this.target, {\n // type: 'to',\n // to: { x: newX, y: newY },\n // duration,\n // easing\n // });\n // }\n\n animator.animate(this.target, {\n type: config.type ?? 'fadeIn',\n to: config.to,\n duration: duration * ratio,\n easing\n });\n this.completeBind(animator);\n }\n}\n\n/**\n * AxisUpdate class handles the update animation for Axis components\n */\nexport class AxisUpdate extends AComponentAnimate<any> {\n onBind(): void {\n const animator = createComponentAnimator(this.target);\n this._animator = animator;\n const duration = this.duration;\n const easing = this.easing;\n const { config, diffAttrs } = this.params;\n // this.target.applyAnimationState(\n // ['update'],\n // [\n // {\n // name: 'update',\n // animation: {\n // type: 'to',\n // to: { ...this.props },\n // duration,\n // easing,\n // customParameters: {\n // diffAttrs: { ...this.props }\n // }\n // }\n // }\n // ]\n // );\n // console.log('this.props', this.props, { ...this.target.attribute });\n animator.animate(this.target, {\n type: config.type ?? 'to',\n to: { ...diffAttrs },\n duration,\n easing,\n customParameters: {\n diffAttrs: { ...diffAttrs }\n }\n });\n this.completeBind(animator);\n }\n\n // 轴动画本身没有逻辑,具体通过animator中执行,所以当需要屏蔽自身属性时,需要通过animator中执行\n deleteSelfAttr(key: string): void {\n super.deleteSelfAttr(key);\n this._animator.deleteSelfAttr(key);\n }\n\n // 轴动画本身没有逻辑,具体通过animator中执行,所以本身不需要屏蔽冲突\n protected tryPreventConflict(): void {\n return;\n }\n}\n\nexport function registerAxisAnimate() {\n // Label update animation\n AnimateExecutor.registerBuiltInAnimate('axisEnter', AxisEnter);\n AnimateExecutor.registerBuiltInAnimate('axisUpdate', AxisUpdate);\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AComponentAnimate } from '@visactor/vrender-animate';
|
|
2
|
+
export declare class LabelUpdate extends AComponentAnimate<any> {
|
|
3
|
+
onBind(): void;
|
|
4
|
+
protected tryPreventConflict(): void;
|
|
5
|
+
}
|
|
6
|
+
export declare class LabelEnter extends AComponentAnimate<any> {
|
|
7
|
+
onBind(): void;
|
|
8
|
+
protected tryPreventConflict(): void;
|
|
9
|
+
}
|
|
10
|
+
export declare function registerLabelAnimate(): void;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __rest = this && this.__rest || function(s, e) {
|
|
4
|
+
var t = {};
|
|
5
|
+
for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]);
|
|
6
|
+
if (null != s && "function" == typeof Object.getOwnPropertySymbols) {
|
|
7
|
+
var i = 0;
|
|
8
|
+
for (p = Object.getOwnPropertySymbols(s); i < p.length; i++) e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]) && (t[p[i]] = s[p[i]]);
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
Object.defineProperty(exports, "__esModule", {
|
|
14
|
+
value: !0
|
|
15
|
+
}), exports.registerLabelAnimate = exports.LabelEnter = exports.LabelUpdate = void 0;
|
|
16
|
+
|
|
17
|
+
const vrender_animate_1 = require("@visactor/vrender-animate");
|
|
18
|
+
|
|
19
|
+
class LabelUpdate extends vrender_animate_1.AComponentAnimate {
|
|
20
|
+
onBind() {
|
|
21
|
+
const animator = (0, vrender_animate_1.createComponentAnimator)(this.target);
|
|
22
|
+
this._animator = animator;
|
|
23
|
+
const duration = this.duration, easing = this.easing, {prevText: prevText, curText: curText, prevLabelLine: prevLabelLine, curLabelLine: curLabelLine} = this.params, diff = {};
|
|
24
|
+
for (const key in curText.attribute) prevText.attribute[key] !== curText.attribute[key] && (diff[key] = curText.attribute[key]);
|
|
25
|
+
const {text: text} = diff, rest = __rest(diff, [ "text" ]);
|
|
26
|
+
animator.animate(prevText, {
|
|
27
|
+
type: "to",
|
|
28
|
+
to: rest,
|
|
29
|
+
duration: duration,
|
|
30
|
+
easing: easing
|
|
31
|
+
}), animator.animate(prevText, {
|
|
32
|
+
type: "increaseCount",
|
|
33
|
+
to: {
|
|
34
|
+
text: curText.attribute.text
|
|
35
|
+
},
|
|
36
|
+
duration: duration,
|
|
37
|
+
easing: easing
|
|
38
|
+
}), prevLabelLine && animator.animate(prevLabelLine, {
|
|
39
|
+
type: "to",
|
|
40
|
+
to: curLabelLine.attribute,
|
|
41
|
+
duration: duration,
|
|
42
|
+
easing: easing
|
|
43
|
+
}), this.completeBind(animator);
|
|
44
|
+
}
|
|
45
|
+
tryPreventConflict() {}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
exports.LabelUpdate = LabelUpdate;
|
|
49
|
+
|
|
50
|
+
class LabelEnter extends vrender_animate_1.AComponentAnimate {
|
|
51
|
+
onBind() {
|
|
52
|
+
const animator = (0, vrender_animate_1.createComponentAnimator)(this.target);
|
|
53
|
+
this._animator = animator;
|
|
54
|
+
const duration = this.duration, easing = this.easing, {relatedGraphic: relatedGraphic, relatedGraphics: relatedGraphics, config: config} = this.params, {mode: mode, type: type = "fadeIn"} = config, target = this.target;
|
|
55
|
+
let startTime = 0;
|
|
56
|
+
"after" === mode ? relatedGraphic.animates && relatedGraphic.animates.forEach((animate => {
|
|
57
|
+
startTime = Math.max(startTime, animate.getStartTime() + animate.getTotalDuration());
|
|
58
|
+
})) : "after-all" === mode ? relatedGraphics && relatedGraphics.forEach((graphic => {
|
|
59
|
+
graphic.animates && graphic.animates.forEach((animate => {
|
|
60
|
+
startTime = Math.max(startTime, animate.getStartTime() + animate.getTotalDuration());
|
|
61
|
+
}));
|
|
62
|
+
})) : relatedGraphic.animates && relatedGraphic.animates.forEach((animate => {
|
|
63
|
+
startTime = Math.max(startTime, animate.getStartTime());
|
|
64
|
+
})), animator.animate(target, Object.assign(Object.assign({}, config), {
|
|
65
|
+
duration: duration,
|
|
66
|
+
easing: easing,
|
|
67
|
+
startTime: startTime,
|
|
68
|
+
type: type
|
|
69
|
+
})), this.completeBind(animator);
|
|
70
|
+
}
|
|
71
|
+
tryPreventConflict() {}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function registerLabelAnimate() {
|
|
75
|
+
vrender_animate_1.AnimateExecutor.registerBuiltInAnimate("labelUpdate", LabelUpdate),
|
|
76
|
+
vrender_animate_1.AnimateExecutor.registerBuiltInAnimate("labelEnter", LabelEnter);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
exports.LabelEnter = LabelEnter, exports.registerLabelAnimate = registerLabelAnimate;
|
|
80
|
+
//# sourceMappingURL=label-animate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/animation/label-animate.ts"],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G,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC;wBACvF,CAAC,CAAC,CAAC;gBACP,CAAC,CAAC,CAAC;SACN;aAAM;YAEL,cAAc,CAAC,QAAQ;gBACrB,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAY,EAAE,EAAE;oBAC/C,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;gBAC1D,CAAC,CAAC,CAAC;SACN;QAED,QAAQ,CAAC,OAAO,CAAC,MAAM,kCAClB,MAAM,KACT,QAAQ;YACR,MAAM;YACN,SAAS;YACT,IAAI,IACJ,CAAC;QAEH,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC;IAGS,kBAAkB;QAC1B,OAAO;IACT,CAAC;CACF;AAlDD,gCAkDC;AAED,SAAgB,oBAAoB;IAElC,iCAAe,CAAC,sBAAsB,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;IACnE,iCAAe,CAAC,sBAAsB,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;AACnE,CAAC;AAJD,oDAIC","file":"label-animate.js","sourcesContent":["import { AComponentAnimate, AnimateExecutor, createComponentAnimator } from '@visactor/vrender-animate';\n\n/**\n * LabelUpdate class handles the update animation for Label components\n */\nexport class LabelUpdate extends AComponentAnimate<any> {\n onBind(): void {\n const animator = createComponentAnimator(this.target);\n this._animator = animator;\n const duration = this.duration;\n const easing = this.easing;\n\n const { prevText, curText, prevLabelLine, curLabelLine } = this.params;\n const diff: Record<string, any> = {};\n\n for (const key in curText.attribute) {\n if (prevText.attribute[key] !== curText.attribute[key]) {\n diff[key] = curText.attribute[key];\n }\n }\n\n const { text, ...rest } = diff;\n\n animator.animate(prevText, {\n type: 'to',\n to: rest,\n duration,\n easing\n });\n\n animator.animate(prevText, {\n type: 'increaseCount',\n to: {\n text: curText.attribute.text\n },\n duration,\n easing\n });\n\n if (prevLabelLine) {\n animator.animate(prevLabelLine, {\n type: 'to',\n to: curLabelLine.attribute,\n duration,\n easing\n });\n }\n\n this.completeBind(animator);\n }\n\n // 标签动画本身没有逻辑,具体通过animator中执行,所以本身不需要屏蔽冲突\n protected tryPreventConflict(): void {\n return;\n }\n}\n\nexport class LabelEnter extends AComponentAnimate<any> {\n onBind(): void {\n const animator = createComponentAnimator(this.target);\n this._animator = animator;\n const duration = this.duration;\n const easing = this.easing;\n\n const { relatedGraphic, relatedGraphics, config } = this.params;\n const { mode, type = 'fadeIn' } = config;\n\n const target = this.target;\n\n let startTime = 0;\n\n if (mode === 'after') {\n relatedGraphic.animates &&\n relatedGraphic.animates.forEach((animate: any) => {\n startTime = Math.max(startTime, animate.getStartTime() + animate.getTotalDuration());\n });\n } else if (mode === 'after-all') {\n relatedGraphics &&\n relatedGraphics.forEach((graphic: any) => {\n graphic.animates &&\n graphic.animates.forEach((animate: any) => {\n startTime = Math.max(startTime, animate.getStartTime() + animate.getTotalDuration());\n });\n });\n } else {\n // 'same-time'\n relatedGraphic.animates &&\n relatedGraphic.animates.forEach((animate: any) => {\n startTime = Math.max(startTime, animate.getStartTime());\n });\n }\n\n animator.animate(target, {\n ...config,\n duration,\n easing,\n startTime,\n type\n });\n\n this.completeBind(animator);\n }\n\n // 标签动画本身没有逻辑,具体通过animator中执行,所以本身不需要屏蔽冲突\n protected tryPreventConflict(): void {\n return;\n }\n}\n\nexport function registerLabelAnimate() {\n // Label update animation\n AnimateExecutor.registerBuiltInAnimate('labelUpdate', LabelUpdate);\n AnimateExecutor.registerBuiltInAnimate('labelEnter', LabelEnter);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/axis/animate/config.ts"],"names":[],"mappings":";;;AAEa,QAAA,oBAAoB,GAAG;IAClC,IAAI,EAAE,SAAS;IACf,QAAQ,EAAE,GAAG;IACb,MAAM,EAAE,QAAsB;CAC/B,CAAC","file":"config.js","sourcesContent":["import type { EasingType } from '@visactor/vrender-core';\n\nexport const DefaultAxisAnimation = {\n type: 'default',\n duration: 300,\n easing: 'linear' as EasingType\n};\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { AnimateMode } from '@visactor/vrender-core';
|
|
1
2
|
import type { IGroup } from '@visactor/vrender-core';
|
|
2
|
-
import { ACustomAnimate
|
|
3
|
+
import { ACustomAnimate } from '@visactor/vrender-animate';
|
|
3
4
|
export declare class GroupTransition extends ACustomAnimate<any> {
|
|
4
5
|
target: IGroup;
|
|
5
6
|
private _newElementAttrMap;
|
|
@@ -4,11 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
}), exports.GroupTransition = void 0;
|
|
6
6
|
|
|
7
|
-
const vrender_animate_1 = require("@visactor/vrender-animate"), vutils_1 = require("@visactor/vutils"), util_1 = require("../../util");
|
|
7
|
+
const vrender_core_1 = require("@visactor/vrender-core"), vrender_animate_1 = require("@visactor/vrender-animate"), vutils_1 = require("@visactor/vutils"), util_1 = require("../../util");
|
|
8
8
|
|
|
9
9
|
class GroupTransition extends vrender_animate_1.ACustomAnimate {
|
|
10
10
|
constructor() {
|
|
11
|
-
super(...arguments), this.mode =
|
|
11
|
+
super(...arguments), this.mode = vrender_core_1.AnimateMode.NORMAL;
|
|
12
12
|
}
|
|
13
13
|
onBind() {
|
|
14
14
|
const currentInnerView = this.target.getInnerView(), prevInnerView = this.target.getPrevInnerView();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/axis/animate/group-transition.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"sources":["../src/axis/animate/group-transition.ts"],"names":[],"mappings":";;;AAAA,yDAAqD;AAErD,+DAA2D;AAE3D,6CAAwF;AACxF,qCAA2C;AAE3C,MAAa,eAAgB,SAAQ,gCAAmB;IAAxD;;QAIE,SAAI,GAAG,0BAAW,CAAC,MAAM,CAAC;IAgG5B,CAAC;IA9FC,MAAM;QAEJ,MAAM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E,cAAmB;4BAC7E,IAAI,GAAG,KAAK,MAAM,EAAE;gCAClB,cAAc,CAAC,IAAI,GAAG,IAAA,0BAAiB,EAAC,IAAI,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;gCACzD,OAAO,IAAI,CAAC;6BACb;4BAED,OAAO,KAAK,CAAC;wBACf,CAAC;qBACF,CAAC;yBAED,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAoB,CAAC,CAAC;iBAC9C;qBAAM;oBACJ,IAAiB;yBACf,OAAO,EAAE;yBAET,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAoB,CAAC,CAAC;iBAC9C;YACH,CAAC,CAAC,CAAC;IACP,CAAC;IAED,QAAQ,CAAC,GAAY,EAAE,KAAa,EAAE,GAAwB;IAE9D,CAAC;CACF;AApGD,0CAoGC","file":"group-transition.js","sourcesContent":["import { AnimateMode } from '@visactor/vrender-core';\nimport type { EasingType, IGraphic, IGroup } from '@visactor/vrender-core';\nimport { ACustomAnimate } from '@visactor/vrender-animate';\nimport type { Dict } from '@visactor/vutils';\nimport { cloneDeep, interpolateString, isEqual, isValidNumber } from '@visactor/vutils';\nimport { traverseGroup } from '../../util';\n\nexport class GroupTransition extends ACustomAnimate<any> {\n declare target: IGroup;\n\n private _newElementAttrMap: Dict<any>;\n mode = AnimateMode.NORMAL; // 组件的群组动画不需要设置走 AnimateMode.SET_ATTR_IMMEDIATELY\n\n onBind(): void {\n // @ts-ignore\n const currentInnerView = this.target.getInnerView();\n // @ts-ignore\n const prevInnerView = this.target.getPrevInnerView();\n if (!prevInnerView) {\n return;\n }\n\n this._newElementAttrMap = {};\n\n // 遍历新的场景树,将新节点属性更新为旧节点\n // TODO: 目前只处理更新场景\n traverseGroup(currentInnerView, (el: IGraphic) => {\n if ((el as IGraphic).type !== 'group' && el.id) {\n const oldEl = prevInnerView[el.id];\n if (oldEl) {\n if (!isEqual((el as IGraphic).attribute, (oldEl as IGraphic).attribute)) {\n // 更新\n const newProps = cloneDeep((el as IGraphic).attribute);\n this._newElementAttrMap[el.id] = {\n state: 'update',\n node: el,\n attrs: {\n ...newProps,\n opacity: newProps.opacity ?? 1,\n fillOpacity: newProps.fillOpacity ?? 1,\n strokeOpacity: newProps.strokeOpacity ?? 1\n }\n };\n\n (el as IGraphic).setAttributes((oldEl as IGraphic).attribute);\n }\n } else {\n // 新入场元素,进行 fadeIn 动画\n const finalOpacityAttrs = {\n opacity: el.attribute.opacity ?? 1,\n fillOpacity: el.attribute.fillOpacity ?? 1,\n strokeOpacity: el.attribute.strokeOpacity ?? 1\n };\n this._newElementAttrMap[el.id] = {\n state: 'enter',\n node: el,\n attrs: finalOpacityAttrs\n };\n (el as IGraphic).setAttributes({\n opacity: 0,\n fillOpacity: 0,\n strokeOpacity: 0\n });\n }\n }\n });\n }\n\n onStart(): void {\n let duration = this.duration;\n let easing = this.easing;\n\n // 新的场景树\n this._newElementAttrMap &&\n Object.keys(this._newElementAttrMap).forEach(id => {\n const { node, attrs, state } = this._newElementAttrMap[id];\n if (state === 'enter') {\n const { enter = {} } = this.params ?? {};\n duration = isValidNumber(enter.duration) ? enter.duration : duration;\n easing = enter.easing ? enter.easing : easing;\n }\n if ((node as IGraphic).type === 'path') {\n (node as IGraphic)\n .animate({\n interpolate(key: string, ratio: number, from: any, to: any, nextAttributes: any) {\n if (key === 'path') {\n nextAttributes.path = interpolateString(from, to)(ratio);\n return true;\n }\n\n return false;\n }\n })\n // .wait(delay)\n .to(attrs, duration, easing as EasingType);\n } else {\n (node as IGraphic)\n .animate()\n // .wait(delay)\n .to(attrs, duration, easing as EasingType);\n }\n });\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n // do nothing\n }\n}\n"]}
|
package/cjs/axis/base.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { IGroup, ITextGraphicAttribute, TextAlignType, TextBaselineType, IGraphic, IText } from '@visactor/vrender-core';
|
|
2
2
|
import type { Dict } from '@visactor/vutils';
|
|
3
|
-
import { AbstractComponent } from '../core/base';
|
|
4
3
|
import type { Point } from '../core/type';
|
|
5
4
|
import type { TagAttributes } from '../tag';
|
|
6
5
|
import type { AxisBaseAttributes, AxisItem, TransformedAxisItem, TickLineItem } from './type';
|
|
7
|
-
|
|
6
|
+
import { AnimateComponent } from '../animation/animate-component';
|
|
7
|
+
import type { IBaseScale } from '@visactor/vscale';
|
|
8
|
+
export declare abstract class AxisBase<T extends AxisBaseAttributes> extends AnimateComponent<Required<T>> {
|
|
8
9
|
name: string;
|
|
10
|
+
lastScale: IBaseScale;
|
|
9
11
|
protected _innerView: IGroup;
|
|
10
12
|
getInnerView(): IGroup;
|
|
11
13
|
protected _prevInnerView: {
|
|
@@ -28,6 +30,7 @@ export declare abstract class AxisBase<T extends AxisBaseAttributes> extends Abs
|
|
|
28
30
|
protected axisContainer: IGroup;
|
|
29
31
|
private _lastHover;
|
|
30
32
|
private _lastSelect;
|
|
33
|
+
protected _newElementAttrMap: Dict<any>;
|
|
31
34
|
protected abstract renderLine(container: IGroup): void;
|
|
32
35
|
abstract isInValidValue(value: number): boolean;
|
|
33
36
|
abstract getTickCoord(value: number): Point;
|
|
@@ -43,6 +46,7 @@ export declare abstract class AxisBase<T extends AxisBaseAttributes> extends Abs
|
|
|
43
46
|
};
|
|
44
47
|
getBoundsWithoutRender(attributes: Partial<T>): import("@visactor/vutils").IBounds;
|
|
45
48
|
protected render(): void;
|
|
49
|
+
protected _prepare(): void;
|
|
46
50
|
private _bindEvent;
|
|
47
51
|
private _onHover;
|
|
48
52
|
private _onUnHover;
|
|
@@ -58,5 +62,6 @@ export declare abstract class AxisBase<T extends AxisBaseAttributes> extends Abs
|
|
|
58
62
|
private _getLabelAttribute;
|
|
59
63
|
protected getLabelPosition(point: Point, vector: [number, number], text: string | number, style: Partial<ITextGraphicAttribute>): Point;
|
|
60
64
|
private _transformItems;
|
|
65
|
+
protected runAnimation(): void;
|
|
61
66
|
release(): void;
|
|
62
67
|
}
|
package/cjs/axis/base.js
CHANGED
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
}), exports.AxisBase = void 0;
|
|
6
6
|
|
|
7
|
-
const vrender_core_1 = require("@visactor/vrender-core"), vutils_1 = require("@visactor/vutils"),
|
|
7
|
+
const vrender_core_1 = require("@visactor/vrender-core"), vutils_1 = require("@visactor/vutils"), util_1 = require("../util"), constant_1 = require("../constant"), constant_2 = require("./constant"), config_1 = require("./config"), tag_1 = require("../tag/tag"), util_2 = require("./util"), interaction_1 = require("../util/interaction"), animate_component_1 = require("../animation/animate-component"), config_2 = require("./animate/config");
|
|
8
8
|
|
|
9
|
-
class AxisBase extends
|
|
9
|
+
class AxisBase extends animate_component_1.AnimateComponent {
|
|
10
10
|
constructor() {
|
|
11
11
|
super(...arguments), this.name = "axis", this.data = [], this.tickLineItems = [],
|
|
12
12
|
this.subTickLineItems = [], this.axisLabelLayerSize = {}, this.axisLabelsContainer = null,
|
|
@@ -26,7 +26,7 @@ class AxisBase extends base_1.AbstractComponent {
|
|
|
26
26
|
}
|
|
27
27
|
getBoundsWithoutRender(attributes) {
|
|
28
28
|
const currentAttribute = (0, vutils_1.cloneDeep)(this.attribute);
|
|
29
|
-
(0, vutils_1.merge)(this.attribute, attributes);
|
|
29
|
+
currentAttribute.scale = this.attribute.scale, (0, vutils_1.merge)(this.attribute, attributes);
|
|
30
30
|
const offscreenGroup = vrender_core_1.graphicCreator.group({
|
|
31
31
|
x: this.attribute.x,
|
|
32
32
|
y: this.attribute.y
|
|
@@ -35,12 +35,16 @@ class AxisBase extends base_1.AbstractComponent {
|
|
|
35
35
|
this.attribute = currentAttribute, offscreenGroup.AABBBounds;
|
|
36
36
|
}
|
|
37
37
|
render() {
|
|
38
|
-
this._prevInnerView = this._innerView && (0, util_2.getElMap)(this._innerView),
|
|
38
|
+
this._prepare(), this._prevInnerView = this._innerView && (0, util_2.getElMap)(this._innerView),
|
|
39
39
|
this.removeAllChild(!0), this._innerView = vrender_core_1.graphicCreator.group({
|
|
40
40
|
x: 0,
|
|
41
41
|
y: 0,
|
|
42
42
|
pickable: !1
|
|
43
|
-
}), this.add(this._innerView), this._renderInner(this._innerView), this._bindEvent()
|
|
43
|
+
}), this.add(this._innerView), this._renderInner(this._innerView), this._bindEvent(),
|
|
44
|
+
this.runAnimation();
|
|
45
|
+
}
|
|
46
|
+
_prepare() {
|
|
47
|
+
this._prepareAnimate(config_2.DefaultAxisAnimation);
|
|
44
48
|
}
|
|
45
49
|
_bindEvent() {
|
|
46
50
|
if (this.attribute.disableTriggerEvent) return;
|
|
@@ -260,6 +264,67 @@ class AxisBase extends base_1.AbstractComponent {
|
|
|
260
264
|
}));
|
|
261
265
|
})), data;
|
|
262
266
|
}
|
|
267
|
+
runAnimation() {
|
|
268
|
+
const lastScale = this.lastScale;
|
|
269
|
+
if (this.attribute.scale) {
|
|
270
|
+
const scale = this.attribute.scale;
|
|
271
|
+
this.lastScale = scale.clone(), this.lastScale.range([ 0, 1 ]);
|
|
272
|
+
}
|
|
273
|
+
if (this.attribute.animation && this.applyAnimationState) {
|
|
274
|
+
const currentInnerView = this.getInnerView(), prevInnerView = this.getPrevInnerView();
|
|
275
|
+
if (!prevInnerView) return;
|
|
276
|
+
const animationConfig = this._animationConfig;
|
|
277
|
+
this._newElementAttrMap = {}, (0, util_1.traverseGroup)(currentInnerView, (el => {
|
|
278
|
+
var _a;
|
|
279
|
+
if ("group" !== el.type && el.id) {
|
|
280
|
+
const oldEl = prevInnerView[el.id];
|
|
281
|
+
if (el.setFinalAttribute(el.attribute), oldEl) {
|
|
282
|
+
oldEl.release();
|
|
283
|
+
const oldAttrs = oldEl.attribute, finalAttrs = el.getFinalAttribute(), diffAttrs = (0,
|
|
284
|
+
vrender_core_1.diff)(oldAttrs, finalAttrs);
|
|
285
|
+
let hasDiff = Object.keys(diffAttrs).length > 0;
|
|
286
|
+
if ("opacity" in oldAttrs && finalAttrs.opacity !== oldAttrs.opacity && (diffAttrs.opacity = null !== (_a = finalAttrs.opacity) && void 0 !== _a ? _a : 1,
|
|
287
|
+
hasDiff = !0), animationConfig.update && hasDiff) {
|
|
288
|
+
this._newElementAttrMap[el.id] = {
|
|
289
|
+
state: "update",
|
|
290
|
+
node: el,
|
|
291
|
+
attrs: el.attribute
|
|
292
|
+
};
|
|
293
|
+
const oldAttrs = oldEl.attribute;
|
|
294
|
+
el.setAttributes(oldAttrs), el.applyAnimationState([ "update" ], [ {
|
|
295
|
+
name: "update",
|
|
296
|
+
animation: Object.assign(Object.assign({
|
|
297
|
+
selfOnly: !0
|
|
298
|
+
}, animationConfig.update), {
|
|
299
|
+
type: "axisUpdate",
|
|
300
|
+
customParameters: {
|
|
301
|
+
config: animationConfig.update,
|
|
302
|
+
diffAttrs: diffAttrs,
|
|
303
|
+
lastScale: lastScale
|
|
304
|
+
}
|
|
305
|
+
})
|
|
306
|
+
} ]);
|
|
307
|
+
}
|
|
308
|
+
} else animationConfig.enter && (this._newElementAttrMap[el.id] = {
|
|
309
|
+
state: "enter",
|
|
310
|
+
node: el,
|
|
311
|
+
attrs: el.attribute
|
|
312
|
+
}, el.applyAnimationState([ "enter" ], [ {
|
|
313
|
+
name: "enter",
|
|
314
|
+
animation: Object.assign(Object.assign({}, animationConfig.enter), {
|
|
315
|
+
type: "axisEnter",
|
|
316
|
+
selfOnly: !0,
|
|
317
|
+
customParameters: {
|
|
318
|
+
config: animationConfig.enter,
|
|
319
|
+
lastScale: lastScale,
|
|
320
|
+
getTickCoord: this.getTickCoord.bind(this)
|
|
321
|
+
}
|
|
322
|
+
})
|
|
323
|
+
} ]));
|
|
324
|
+
}
|
|
325
|
+
}));
|
|
326
|
+
}
|
|
327
|
+
}
|
|
263
328
|
release() {
|
|
264
329
|
super.release(), this._prevInnerView = null, this._innerView = null;
|
|
265
330
|
}
|