@visactor/vrender-animate 1.0.5 → 1.0.6-alpha.0
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/custom/move.d.ts +4 -4
- package/cjs/custom/move.js +8 -7
- package/cjs/custom/move.js.map +1 -1
- package/dist/index.es.js +9 -10
- package/es/custom/move.d.ts +4 -4
- package/es/custom/move.js +6 -6
- package/es/custom/move.js.map +1 -1
- package/package.json +2 -2
package/cjs/custom/move.d.ts
CHANGED
|
@@ -56,7 +56,7 @@ export declare const moveIn: (graphic: IGraphic, options: IMoveAnimationOptions,
|
|
|
56
56
|
};
|
|
57
57
|
export declare const moveOut: (graphic: IGraphic, options: IMoveAnimationOptions, animationParameters: IAnimationParameters) => {
|
|
58
58
|
from: {
|
|
59
|
-
x:
|
|
59
|
+
x: any;
|
|
60
60
|
y?: undefined;
|
|
61
61
|
};
|
|
62
62
|
to: {
|
|
@@ -65,7 +65,7 @@ export declare const moveOut: (graphic: IGraphic, options: IMoveAnimationOptions
|
|
|
65
65
|
};
|
|
66
66
|
} | {
|
|
67
67
|
from: {
|
|
68
|
-
y:
|
|
68
|
+
y: any;
|
|
69
69
|
x?: undefined;
|
|
70
70
|
};
|
|
71
71
|
to: {
|
|
@@ -74,8 +74,8 @@ export declare const moveOut: (graphic: IGraphic, options: IMoveAnimationOptions
|
|
|
74
74
|
};
|
|
75
75
|
} | {
|
|
76
76
|
from: {
|
|
77
|
-
x:
|
|
78
|
-
y:
|
|
77
|
+
x: any;
|
|
78
|
+
y: any;
|
|
79
79
|
};
|
|
80
80
|
to: {
|
|
81
81
|
x: any;
|
package/cjs/custom/move.js
CHANGED
|
@@ -11,13 +11,14 @@ const vutils_1 = require("@visactor/vutils"), custom_animate_1 = require("./cust
|
|
|
11
11
|
"negative" === orient && (changedX = null !== (_a = layoutRect.width) && void 0 !== _a ? _a : graphic.stage.viewWidth,
|
|
12
12
|
changedY = null !== (_b = layoutRect.height) && void 0 !== _b ? _b : graphic.stage.viewHeight),
|
|
13
13
|
changedX += offset, changedY += offset;
|
|
14
|
-
const point = (0, vutils_1.isFunction)(pointOpt) ? pointOpt.call(null, null === (_d = null === (_c = graphic.context) || void 0 === _c ? void 0 : _c.data) || void 0 === _d ? void 0 : _d[0], graphic, animationParameters) : pointOpt, fromX = point && (0,
|
|
15
|
-
vutils_1.isValidNumber)(point.x) ? point.x : changedX, fromY =
|
|
14
|
+
const point = (0, vutils_1.isFunction)(pointOpt) ? pointOpt.call(null, null === (_d = null === (_c = graphic.context) || void 0 === _c ? void 0 : _c.data) || void 0 === _d ? void 0 : _d[0], graphic, animationParameters) : pointOpt, finalAttrsX = graphic.getGraphicAttribute("x"), finalAttrsY = graphic.getGraphicAttribute("y"), fromX = excludeChannels.includes("x") ? finalAttrsX : point && (0,
|
|
15
|
+
vutils_1.isValidNumber)(point.x) ? point.x : changedX, fromY = excludeChannels.includes("y") ? finalAttrsY : point && (0,
|
|
16
|
+
vutils_1.isValidNumber)(point.y) ? point.y : changedY;
|
|
16
17
|
switch (direction) {
|
|
17
18
|
case "x":
|
|
18
19
|
return {
|
|
19
20
|
from: {
|
|
20
|
-
x: fromX
|
|
21
|
+
x: excludeChannels.includes("x") ? finalAttrsX : fromX
|
|
21
22
|
},
|
|
22
23
|
to: {
|
|
23
24
|
x: finalAttrsX
|
|
@@ -59,7 +60,7 @@ const moveOut = (graphic, options, animationParameters) => {
|
|
|
59
60
|
case "x":
|
|
60
61
|
return {
|
|
61
62
|
from: {
|
|
62
|
-
x: graphic.
|
|
63
|
+
x: graphic.getGraphicAttribute("x")
|
|
63
64
|
},
|
|
64
65
|
to: {
|
|
65
66
|
x: fromX
|
|
@@ -69,7 +70,7 @@ const moveOut = (graphic, options, animationParameters) => {
|
|
|
69
70
|
case "y":
|
|
70
71
|
return {
|
|
71
72
|
from: {
|
|
72
|
-
y: graphic.
|
|
73
|
+
y: graphic.getGraphicAttribute("y")
|
|
73
74
|
},
|
|
74
75
|
to: {
|
|
75
76
|
y: fromY
|
|
@@ -79,8 +80,8 @@ const moveOut = (graphic, options, animationParameters) => {
|
|
|
79
80
|
default:
|
|
80
81
|
return {
|
|
81
82
|
from: {
|
|
82
|
-
x: graphic.
|
|
83
|
-
y: graphic.
|
|
83
|
+
x: graphic.getGraphicAttribute("x"),
|
|
84
|
+
y: graphic.getGraphicAttribute("y")
|
|
84
85
|
},
|
|
85
86
|
to: {
|
|
86
87
|
x: fromX,
|
package/cjs/custom/move.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/custom/move.ts"],"names":[],"mappings":";;;AACA,6CAA6D;AAC7D,qDAAkD;AAyB3C,MAAM,MAAM,GAAG,CACpB,OAAiB,EACjB,OAA8B,EAC9B,mBAAyC,EACzC,EAAE;;IACF,MAAM,EAAE,MAAM,GAAG,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,eAAe,GAAG,EAAE,EAAE,UAAU,GAAG,EAAE,EAAE,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,CAAC;IAChH,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,IAAI,QAAQ,GAAG,CAAC,CAAC;IAEjB,IAAI,MAAM,KAAK,UAAU,EAAE;QACzB,QAAQ,GAAG,MAAC,UAAkB,CAAC,KAAK,mCAAI,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC;QAChE,QAAQ,GAAG,MAAC,UAAkB,CAAC,MAAM,mCAAI,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC;KACnE;IAED,QAAQ,IAAI,MAAM,CAAC;IACnB,QAAQ,IAAI,MAAM,CAAC;IACnB,MAAM,KAAK,GAAG,IAAA,mBAAU,EAAC,QAAQ,CAAC;QAChC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,MAAA,MAAA,OAAO,CAAC,OAAO,0CAAE,IAAI,0CAAG,CAAC,CAAC,EAAE,OAAO,E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eAAO,EAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAC5E,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAE,EAAU,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC;QACxE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,CAAC;CACF;AATD,0BASC","file":"move.js","sourcesContent":["import type { EasingType, IGraphic, IGroup } from '@visactor/vrender-core';\nimport { isFunction, isValidNumber } from '@visactor/vutils';\nimport { ACustomAnimate } from './custom-animate';\n\nexport type FunctionCallback<T> = (...args: any[]) => T;\n\nexport interface IMoveAnimationOptions {\n direction?: 'x' | 'y' | 'xy';\n orient?: 'positive' | 'negative';\n offset?: number;\n point?: { x?: number; y?: number } | FunctionCallback<{ x?: number; y?: number }>;\n excludeChannels?: string[];\n layoutRect?: { width: number; height: number };\n}\n\ninterface IAnimationParameters {\n width: number;\n height: number;\n group: IGroup;\n elementIndex: number;\n elementCount: number;\n view: any;\n}\n\n// When user did not provide proper x/y value, move animation will never work properly,\n// due to that, default x/y value won't be set.\n\nexport const moveIn = (\n graphic: IGraphic,\n options: IMoveAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const { offset = 0, orient, direction, point: pointOpt, excludeChannels = [], layoutRect = {} } = options ?? {};\n let changedX = 0;\n let changedY = 0;\n\n if (orient === 'negative') {\n changedX = (layoutRect as any).width ?? graphic.stage.viewWidth;\n changedY = (layoutRect as any).height ?? graphic.stage.viewHeight;\n }\n\n changedX += offset;\n changedY += offset;\n const point = isFunction(pointOpt)\n ? pointOpt.call(null, graphic.context?.data?.[0], graphic, animationParameters)\n : pointOpt;\n const fromX = point && isValidNumber(point.x) ? point.x : changedX;\n const fromY = point && isValidNumber(point.y) ? point.y : changedY;\n const finalAttrs = graphic.getFinalAttribute();\n const finalAttrsX = excludeChannels.includes('x') ? graphic.attribute.x : finalAttrs.x;\n const finalAttrsY = excludeChannels.includes('y') ? graphic.attribute.y : finalAttrs.y;\n\n switch (direction) {\n case 'x':\n return {\n from: { x: fromX },\n to: { x: finalAttrsX }\n };\n case 'y':\n return {\n from: { y: fromY },\n to: { y: finalAttrsY }\n };\n case 'xy':\n default:\n return {\n from: { x: fromX, y: fromY },\n to: {\n x: finalAttrsX,\n y: finalAttrsY\n }\n };\n }\n};\n\nexport const moveOut = (\n graphic: IGraphic,\n options: IMoveAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const { offset = 0, orient, direction, point: pointOpt } = options ?? {};\n\n const groupBounds = animationParameters.group ? animationParameters.group.AABBBounds : null;\n const groupWidth = groupBounds.width() ?? animationParameters.width;\n const groupHeight = groupBounds.height() ?? animationParameters.height;\n const changedX = (orient === 'negative' ? groupWidth : 0) + offset;\n const changedY = (orient === 'negative' ? groupHeight : 0) + offset;\n const point = isFunction(pointOpt)\n ? pointOpt.call(null, graphic.context?.data?.[0], graphic, animationParameters)\n : pointOpt;\n const fromX = point && isValidNumber(point.x) ? point.x : changedX;\n const fromY = point && isValidNumber(point.y) ? point.y : changedY;\n\n switch (direction) {\n case 'x':\n return {\n from: { x: graphic.attribute.x },\n to: { x: fromX }\n };\n case 'y':\n return {\n from: { y: graphic.attribute.y },\n to: { y: fromY }\n };\n case 'xy':\n default:\n return {\n from: {\n x: graphic.attribute.x,\n y: graphic.attribute.y\n },\n to: { x: fromX, y: fromY }\n };\n }\n};\n\nexport class MoveBase extends ACustomAnimate<Record<string, number>> {\n declare valid: boolean;\n\n constructor(from: null, to: null, duration: number, easing: EasingType, params?: any) {\n super(from, to, duration, easing, params);\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n const attribute: Record<string, any> = this.target.attribute;\n this.propKeys.forEach(key => {\n attribute[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;\n });\n this.target.addUpdatePositionTag();\n this.target.addUpdateShapeAndBoundsTag();\n }\n}\n\n/**\n * 增长渐入\n */\nexport class MoveIn extends MoveBase {\n onBind(): void {\n super.onBind();\n const { from, to } = moveIn(this.target, this.params.options, this.params);\n this.props = to;\n this.propKeys = Object.keys(to).filter(key => (to as any)[key] != null);\n this.from = from;\n this.to = to;\n\n // 用于入场的时候设置属性(因为有动画的时候VChart不会再设置属性了)\n const finalAttribute = this.target.getFinalAttribute();\n if (finalAttribute) {\n this.target.setAttributes(finalAttribute);\n }\n\n if (this.params.controlOptions?.immediatelyApply !== false) {\n this.target.setAttributes(from);\n }\n }\n}\n\nexport class MoveOut extends MoveBase {\n onBind(): void {\n super.onBind();\n const { from, to } = moveOut(this.target, this.params.options, this.params);\n this.props = to;\n this.propKeys = Object.keys(to).filter(key => (to as any)[key] != null);\n this.from = from;\n this.to = to;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/custom/move.ts"],"names":[],"mappings":";;;AACA,6CAA6D;AAC7D,qDAAkD;AAyB3C,MAAM,MAAM,GAAG,CACpB,OAAiB,EACjB,OAA8B,EAC9B,mBAAyC,EACzC,EAAE;;IACF,MAAM,EAAE,MAAM,GAAG,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,eAAe,GAAG,EAAE,EAAE,UAAU,GAAG,EAAE,EAAE,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,CAAC;IAChH,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,IAAI,QAAQ,GAAG,CAAC,CAAC;IAEjB,IAAI,MAAM,KAAK,UAAU,EAAE;QACzB,QAAQ,GAAG,MAAC,UAAkB,CAAC,KAAK,mCAAI,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC;QAChE,QAAQ,GAAG,MAAC,UAAkB,CAAC,MAAM,mCAAI,O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c,CAAC,CAAC;SAC3C;QAED,IAAI,CAAA,MAAA,IAAI,CAAC,MAAM,CAAC,cAAc,0CAAE,gBAAgB,MAAK,KAAK,EAAE;YAC1D,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;SACjC;IACH,CAAC;CACF;AAnBD,wBAmBC;AAED,MAAa,OAAQ,SAAQ,QAAQ;IACnC,MAAM;QACJ,KAAK,CAAC,MAAM,EAAE,CAAC;QACf,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,IAAA,eAAO,EAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAC5E,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAE,EAAU,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC;QACxE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,CAAC;CACF;AATD,0BASC","file":"move.js","sourcesContent":["import type { EasingType, IGraphic, IGroup } from '@visactor/vrender-core';\nimport { isFunction, isValidNumber } from '@visactor/vutils';\nimport { ACustomAnimate } from './custom-animate';\n\nexport type FunctionCallback<T> = (...args: any[]) => T;\n\nexport interface IMoveAnimationOptions {\n direction?: 'x' | 'y' | 'xy';\n orient?: 'positive' | 'negative';\n offset?: number;\n point?: { x?: number; y?: number } | FunctionCallback<{ x?: number; y?: number }>;\n excludeChannels?: string[];\n layoutRect?: { width: number; height: number };\n}\n\ninterface IAnimationParameters {\n width: number;\n height: number;\n group: IGroup;\n elementIndex: number;\n elementCount: number;\n view: any;\n}\n\n// When user did not provide proper x/y value, move animation will never work properly,\n// due to that, default x/y value won't be set.\n\nexport const moveIn = (\n graphic: IGraphic,\n options: IMoveAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const { offset = 0, orient, direction, point: pointOpt, excludeChannels = [], layoutRect = {} } = options ?? {};\n let changedX = 0;\n let changedY = 0;\n\n if (orient === 'negative') {\n changedX = (layoutRect as any).width ?? graphic.stage.viewWidth;\n changedY = (layoutRect as any).height ?? graphic.stage.viewHeight;\n }\n\n changedX += offset;\n changedY += offset;\n const point = isFunction(pointOpt)\n ? pointOpt.call(null, graphic.context?.data?.[0], graphic, animationParameters)\n : pointOpt;\n const finalAttrsX = graphic.getGraphicAttribute('x');\n const finalAttrsY = graphic.getGraphicAttribute('y');\n const fromX = excludeChannels.includes('x') ? finalAttrsX : point && isValidNumber(point.x) ? point.x : changedX;\n const fromY = excludeChannels.includes('y') ? finalAttrsY : point && isValidNumber(point.y) ? point.y : changedY;\n\n switch (direction) {\n case 'x':\n return {\n from: { x: excludeChannels.includes('x') ? finalAttrsX : fromX },\n to: { x: finalAttrsX }\n };\n case 'y':\n return {\n from: { y: fromY },\n to: { y: finalAttrsY }\n };\n case 'xy':\n default:\n return {\n from: { x: fromX, y: fromY },\n to: {\n x: finalAttrsX,\n y: finalAttrsY\n }\n };\n }\n};\n\nexport const moveOut = (\n graphic: IGraphic,\n options: IMoveAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const { offset = 0, orient, direction, point: pointOpt } = options ?? {};\n\n const groupBounds = animationParameters.group ? animationParameters.group.AABBBounds : null;\n const groupWidth = groupBounds.width() ?? animationParameters.width;\n const groupHeight = groupBounds.height() ?? animationParameters.height;\n const changedX = (orient === 'negative' ? groupWidth : 0) + offset;\n const changedY = (orient === 'negative' ? groupHeight : 0) + offset;\n const point = isFunction(pointOpt)\n ? pointOpt.call(null, graphic.context?.data?.[0], graphic, animationParameters)\n : pointOpt;\n const fromX = point && isValidNumber(point.x) ? point.x : changedX;\n const fromY = point && isValidNumber(point.y) ? point.y : changedY;\n\n switch (direction) {\n case 'x':\n return {\n from: { x: graphic.getGraphicAttribute('x') },\n to: { x: fromX }\n };\n case 'y':\n return {\n from: { y: graphic.getGraphicAttribute('y') },\n to: { y: fromY }\n };\n case 'xy':\n default:\n return {\n from: {\n x: graphic.getGraphicAttribute('x'),\n y: graphic.getGraphicAttribute('y')\n },\n to: { x: fromX, y: fromY }\n };\n }\n};\n\nexport class MoveBase extends ACustomAnimate<Record<string, number>> {\n declare valid: boolean;\n\n constructor(from: null, to: null, duration: number, easing: EasingType, params?: any) {\n super(from, to, duration, easing, params);\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n const attribute: Record<string, any> = this.target.attribute;\n this.propKeys.forEach(key => {\n attribute[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;\n });\n this.target.addUpdatePositionTag();\n this.target.addUpdateShapeAndBoundsTag();\n }\n}\n\n/**\n * 增长渐入\n */\nexport class MoveIn extends MoveBase {\n onBind(): void {\n super.onBind();\n const { from, to } = moveIn(this.target, this.params.options, this.params);\n this.props = to;\n this.propKeys = Object.keys(to).filter(key => (to as any)[key] != null);\n this.from = from;\n this.to = to;\n\n // 用于入场的时候设置属性(因为有动画的时候VChart不会再设置属性了)\n const finalAttribute = this.target.getFinalAttribute();\n if (finalAttribute) {\n this.target.setAttributes(finalAttribute);\n }\n\n if (this.params.controlOptions?.immediatelyApply !== false) {\n this.target.setAttributes(from);\n }\n }\n}\n\nexport class MoveOut extends MoveBase {\n onBind(): void {\n super.onBind();\n const { from, to } = moveOut(this.target, this.params.options, this.params);\n this.props = to;\n this.propKeys = Object.keys(to).filter(key => (to as any)[key] != null);\n this.from = from;\n this.to = to;\n }\n}\n"]}
|
package/dist/index.es.js
CHANGED
|
@@ -6496,15 +6496,14 @@ const moveIn = (graphic, options, animationParameters) => {
|
|
|
6496
6496
|
const point = isFunction(pointOpt)
|
|
6497
6497
|
? pointOpt.call(null, (_d = (_c = graphic.context) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d[0], graphic, animationParameters)
|
|
6498
6498
|
: pointOpt;
|
|
6499
|
-
const
|
|
6500
|
-
const
|
|
6501
|
-
const
|
|
6502
|
-
const
|
|
6503
|
-
const finalAttrsY = excludeChannels.includes('y') ? graphic.attribute.y : finalAttrs.y;
|
|
6499
|
+
const finalAttrsX = graphic.getGraphicAttribute('x');
|
|
6500
|
+
const finalAttrsY = graphic.getGraphicAttribute('y');
|
|
6501
|
+
const fromX = excludeChannels.includes('x') ? finalAttrsX : point && isValidNumber(point.x) ? point.x : changedX;
|
|
6502
|
+
const fromY = excludeChannels.includes('y') ? finalAttrsY : point && isValidNumber(point.y) ? point.y : changedY;
|
|
6504
6503
|
switch (direction) {
|
|
6505
6504
|
case 'x':
|
|
6506
6505
|
return {
|
|
6507
|
-
from: { x: fromX },
|
|
6506
|
+
from: { x: excludeChannels.includes('x') ? finalAttrsX : fromX },
|
|
6508
6507
|
to: { x: finalAttrsX }
|
|
6509
6508
|
};
|
|
6510
6509
|
case 'y':
|
|
@@ -6539,20 +6538,20 @@ const moveOut = (graphic, options, animationParameters) => {
|
|
|
6539
6538
|
switch (direction) {
|
|
6540
6539
|
case 'x':
|
|
6541
6540
|
return {
|
|
6542
|
-
from: { x: graphic.
|
|
6541
|
+
from: { x: graphic.getGraphicAttribute('x') },
|
|
6543
6542
|
to: { x: fromX }
|
|
6544
6543
|
};
|
|
6545
6544
|
case 'y':
|
|
6546
6545
|
return {
|
|
6547
|
-
from: { y: graphic.
|
|
6546
|
+
from: { y: graphic.getGraphicAttribute('y') },
|
|
6548
6547
|
to: { y: fromY }
|
|
6549
6548
|
};
|
|
6550
6549
|
case 'xy':
|
|
6551
6550
|
default:
|
|
6552
6551
|
return {
|
|
6553
6552
|
from: {
|
|
6554
|
-
x: graphic.
|
|
6555
|
-
y: graphic.
|
|
6553
|
+
x: graphic.getGraphicAttribute('x'),
|
|
6554
|
+
y: graphic.getGraphicAttribute('y')
|
|
6556
6555
|
},
|
|
6557
6556
|
to: { x: fromX, y: fromY }
|
|
6558
6557
|
};
|
package/es/custom/move.d.ts
CHANGED
|
@@ -56,7 +56,7 @@ export declare const moveIn: (graphic: IGraphic, options: IMoveAnimationOptions,
|
|
|
56
56
|
};
|
|
57
57
|
export declare const moveOut: (graphic: IGraphic, options: IMoveAnimationOptions, animationParameters: IAnimationParameters) => {
|
|
58
58
|
from: {
|
|
59
|
-
x:
|
|
59
|
+
x: any;
|
|
60
60
|
y?: undefined;
|
|
61
61
|
};
|
|
62
62
|
to: {
|
|
@@ -65,7 +65,7 @@ export declare const moveOut: (graphic: IGraphic, options: IMoveAnimationOptions
|
|
|
65
65
|
};
|
|
66
66
|
} | {
|
|
67
67
|
from: {
|
|
68
|
-
y:
|
|
68
|
+
y: any;
|
|
69
69
|
x?: undefined;
|
|
70
70
|
};
|
|
71
71
|
to: {
|
|
@@ -74,8 +74,8 @@ export declare const moveOut: (graphic: IGraphic, options: IMoveAnimationOptions
|
|
|
74
74
|
};
|
|
75
75
|
} | {
|
|
76
76
|
from: {
|
|
77
|
-
x:
|
|
78
|
-
y:
|
|
77
|
+
x: any;
|
|
78
|
+
y: any;
|
|
79
79
|
};
|
|
80
80
|
to: {
|
|
81
81
|
x: any;
|
package/es/custom/move.js
CHANGED
|
@@ -9,12 +9,12 @@ export const moveIn = (graphic, options, animationParameters) => {
|
|
|
9
9
|
"negative" === orient && (changedX = null !== (_a = layoutRect.width) && void 0 !== _a ? _a : graphic.stage.viewWidth,
|
|
10
10
|
changedY = null !== (_b = layoutRect.height) && void 0 !== _b ? _b : graphic.stage.viewHeight),
|
|
11
11
|
changedX += offset, changedY += offset;
|
|
12
|
-
const point = isFunction(pointOpt) ? pointOpt.call(null, null === (_d = null === (_c = graphic.context) || void 0 === _c ? void 0 : _c.data) || void 0 === _d ? void 0 : _d[0], graphic, animationParameters) : pointOpt,
|
|
12
|
+
const point = isFunction(pointOpt) ? pointOpt.call(null, null === (_d = null === (_c = graphic.context) || void 0 === _c ? void 0 : _c.data) || void 0 === _d ? void 0 : _d[0], graphic, animationParameters) : pointOpt, finalAttrsX = graphic.getGraphicAttribute("x"), finalAttrsY = graphic.getGraphicAttribute("y"), fromX = excludeChannels.includes("x") ? finalAttrsX : point && isValidNumber(point.x) ? point.x : changedX, fromY = excludeChannels.includes("y") ? finalAttrsY : point && isValidNumber(point.y) ? point.y : changedY;
|
|
13
13
|
switch (direction) {
|
|
14
14
|
case "x":
|
|
15
15
|
return {
|
|
16
16
|
from: {
|
|
17
|
-
x: fromX
|
|
17
|
+
x: excludeChannels.includes("x") ? finalAttrsX : fromX
|
|
18
18
|
},
|
|
19
19
|
to: {
|
|
20
20
|
x: finalAttrsX
|
|
@@ -52,7 +52,7 @@ export const moveOut = (graphic, options, animationParameters) => {
|
|
|
52
52
|
case "x":
|
|
53
53
|
return {
|
|
54
54
|
from: {
|
|
55
|
-
x: graphic.
|
|
55
|
+
x: graphic.getGraphicAttribute("x")
|
|
56
56
|
},
|
|
57
57
|
to: {
|
|
58
58
|
x: fromX
|
|
@@ -62,7 +62,7 @@ export const moveOut = (graphic, options, animationParameters) => {
|
|
|
62
62
|
case "y":
|
|
63
63
|
return {
|
|
64
64
|
from: {
|
|
65
|
-
y: graphic.
|
|
65
|
+
y: graphic.getGraphicAttribute("y")
|
|
66
66
|
},
|
|
67
67
|
to: {
|
|
68
68
|
y: fromY
|
|
@@ -72,8 +72,8 @@ export const moveOut = (graphic, options, animationParameters) => {
|
|
|
72
72
|
default:
|
|
73
73
|
return {
|
|
74
74
|
from: {
|
|
75
|
-
x: graphic.
|
|
76
|
-
y: graphic.
|
|
75
|
+
x: graphic.getGraphicAttribute("x"),
|
|
76
|
+
y: graphic.getGraphicAttribute("y")
|
|
77
77
|
},
|
|
78
78
|
to: {
|
|
79
79
|
x: fromX,
|
package/es/custom/move.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/custom/move.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC7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isFunction, isValidNumber } from '@visactor/vutils';\nimport { ACustomAnimate } from './custom-animate';\n\nexport type FunctionCallback<T> = (...args: any[]) => T;\n\nexport interface IMoveAnimationOptions {\n direction?: 'x' | 'y' | 'xy';\n orient?: 'positive' | 'negative';\n offset?: number;\n point?: { x?: number; y?: number } | FunctionCallback<{ x?: number; y?: number }>;\n excludeChannels?: string[];\n layoutRect?: { width: number; height: number };\n}\n\ninterface IAnimationParameters {\n width: number;\n height: number;\n group: IGroup;\n elementIndex: number;\n elementCount: number;\n view: any;\n}\n\n// When user did not provide proper x/y value, move animation will never work properly,\n// due to that, default x/y value won't be set.\n\nexport const moveIn = (\n graphic: IGraphic,\n options: IMoveAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const { offset = 0, orient, direction, point: pointOpt, excludeChannels = [], layoutRect = {} } = options ?? {};\n let changedX = 0;\n let changedY = 0;\n\n if (orient === 'negative') {\n changedX = (layoutRect as any).width ?? graphic.stage.viewWidth;\n changedY = (layoutRect as any).height ?? graphic.stage.viewHeight;\n }\n\n changedX += offset;\n changedY += offset;\n const point = isFunction(pointOpt)\n ? pointOpt.call(null, graphic.context?.data?.[0], graphic, animationParameters)\n : pointOpt;\n const fromX = point && isValidNumber(point.x) ? point.x : changedX;\n const fromY = point && isValidNumber(point.y) ? point.y : changedY;\n const finalAttrs = graphic.getFinalAttribute();\n const finalAttrsX = excludeChannels.includes('x') ? graphic.attribute.x : finalAttrs.x;\n const finalAttrsY = excludeChannels.includes('y') ? graphic.attribute.y : finalAttrs.y;\n\n switch (direction) {\n case 'x':\n return {\n from: { x: fromX },\n to: { x: finalAttrsX }\n };\n case 'y':\n return {\n from: { y: fromY },\n to: { y: finalAttrsY }\n };\n case 'xy':\n default:\n return {\n from: { x: fromX, y: fromY },\n to: {\n x: finalAttrsX,\n y: finalAttrsY\n }\n };\n }\n};\n\nexport const moveOut = (\n graphic: IGraphic,\n options: IMoveAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const { offset = 0, orient, direction, point: pointOpt } = options ?? {};\n\n const groupBounds = animationParameters.group ? animationParameters.group.AABBBounds : null;\n const groupWidth = groupBounds.width() ?? animationParameters.width;\n const groupHeight = groupBounds.height() ?? animationParameters.height;\n const changedX = (orient === 'negative' ? groupWidth : 0) + offset;\n const changedY = (orient === 'negative' ? groupHeight : 0) + offset;\n const point = isFunction(pointOpt)\n ? pointOpt.call(null, graphic.context?.data?.[0], graphic, animationParameters)\n : pointOpt;\n const fromX = point && isValidNumber(point.x) ? point.x : changedX;\n const fromY = point && isValidNumber(point.y) ? point.y : changedY;\n\n switch (direction) {\n case 'x':\n return {\n from: { x: graphic.attribute.x },\n to: { x: fromX }\n };\n case 'y':\n return {\n from: { y: graphic.attribute.y },\n to: { y: fromY }\n };\n case 'xy':\n default:\n return {\n from: {\n x: graphic.attribute.x,\n y: graphic.attribute.y\n },\n to: { x: fromX, y: fromY }\n };\n }\n};\n\nexport class MoveBase extends ACustomAnimate<Record<string, number>> {\n declare valid: boolean;\n\n constructor(from: null, to: null, duration: number, easing: EasingType, params?: any) {\n super(from, to, duration, easing, params);\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n const attribute: Record<string, any> = this.target.attribute;\n this.propKeys.forEach(key => {\n attribute[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;\n });\n this.target.addUpdatePositionTag();\n this.target.addUpdateShapeAndBoundsTag();\n }\n}\n\n/**\n * 增长渐入\n */\nexport class MoveIn extends MoveBase {\n onBind(): void {\n super.onBind();\n const { from, to } = moveIn(this.target, this.params.options, this.params);\n this.props = to;\n this.propKeys = Object.keys(to).filter(key => (to as any)[key] != null);\n this.from = from;\n this.to = to;\n\n // 用于入场的时候设置属性(因为有动画的时候VChart不会再设置属性了)\n const finalAttribute = this.target.getFinalAttribute();\n if (finalAttribute) {\n this.target.setAttributes(finalAttribute);\n }\n\n if (this.params.controlOptions?.immediatelyApply !== false) {\n this.target.setAttributes(from);\n }\n }\n}\n\nexport class MoveOut extends MoveBase {\n onBind(): void {\n super.onBind();\n const { from, to } = moveOut(this.target, this.params.options, this.params);\n this.props = to;\n this.propKeys = Object.keys(to).filter(key => (to as any)[key] != null);\n this.from = from;\n this.to = to;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/custom/move.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAyBlD,MAAM,CAAC,MAAM,MAAM,GAAG,CACpB,OAAiB,EACjB,OAA8B,EAC9B,mBAAyC,EACzC,EAAE;;IACF,MAAM,EAAE,MAAM,GAAG,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,eAAe,GAAG,EAAE,EAAE,UAAU,GAAG,EAAE,EAAE,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,CAAC;IAChH,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,IAAI,QAAQ,GAAG,CAAC,CAAC;IAEjB,IAAI,MAAM,KAAK,UAAU,EAAE;QACzB,QAAQ,GAAG,MAAC,UAAkB,CAAC,KAAK,mCAAI,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC;QAChE,QAAQ,GAAG,MAAC,UAAkB,CAAC,MAAM,mCAAI,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC;KACnE;IAED,QAAQ,IAAI,MAAM,CAAC;IACnB,QAAQ,IAAI,MAAM,CAAC;IACnB,MAAM,KAAK,GAAG,UAAU,CAAC,QAAQ,CAAC;QAChC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,MAAA,MAAA,OAAO,CAAC,OAAO,0CAAE,IAAI,0CAAG,CAAC,CAAC,EAAE,OAAO,EAAE,mBAAmB,CAAC;QAC/E,CAAC,CAAC,QAAQ,CAAC;IACb,MAAM,WAAW,GAAG,OAAO,CAAC,mBAAmB,CAAC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IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAE,EAAU,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC;QACxE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,CAAC;CACF","file":"move.js","sourcesContent":["import type { EasingType, IGraphic, IGroup } from '@visactor/vrender-core';\nimport { isFunction, isValidNumber } from '@visactor/vutils';\nimport { ACustomAnimate } from './custom-animate';\n\nexport type FunctionCallback<T> = (...args: any[]) => T;\n\nexport interface IMoveAnimationOptions {\n direction?: 'x' | 'y' | 'xy';\n orient?: 'positive' | 'negative';\n offset?: number;\n point?: { x?: number; y?: number } | FunctionCallback<{ x?: number; y?: number }>;\n excludeChannels?: string[];\n layoutRect?: { width: number; height: number };\n}\n\ninterface IAnimationParameters {\n width: number;\n height: number;\n group: IGroup;\n elementIndex: number;\n elementCount: number;\n view: any;\n}\n\n// When user did not provide proper x/y value, move animation will never work properly,\n// due to that, default x/y value won't be set.\n\nexport const moveIn = (\n graphic: IGraphic,\n options: IMoveAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const { offset = 0, orient, direction, point: pointOpt, excludeChannels = [], layoutRect = {} } = options ?? {};\n let changedX = 0;\n let changedY = 0;\n\n if (orient === 'negative') {\n changedX = (layoutRect as any).width ?? graphic.stage.viewWidth;\n changedY = (layoutRect as any).height ?? graphic.stage.viewHeight;\n }\n\n changedX += offset;\n changedY += offset;\n const point = isFunction(pointOpt)\n ? pointOpt.call(null, graphic.context?.data?.[0], graphic, animationParameters)\n : pointOpt;\n const finalAttrsX = graphic.getGraphicAttribute('x');\n const finalAttrsY = graphic.getGraphicAttribute('y');\n const fromX = excludeChannels.includes('x') ? finalAttrsX : point && isValidNumber(point.x) ? point.x : changedX;\n const fromY = excludeChannels.includes('y') ? finalAttrsY : point && isValidNumber(point.y) ? point.y : changedY;\n\n switch (direction) {\n case 'x':\n return {\n from: { x: excludeChannels.includes('x') ? finalAttrsX : fromX },\n to: { x: finalAttrsX }\n };\n case 'y':\n return {\n from: { y: fromY },\n to: { y: finalAttrsY }\n };\n case 'xy':\n default:\n return {\n from: { x: fromX, y: fromY },\n to: {\n x: finalAttrsX,\n y: finalAttrsY\n }\n };\n }\n};\n\nexport const moveOut = (\n graphic: IGraphic,\n options: IMoveAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const { offset = 0, orient, direction, point: pointOpt } = options ?? {};\n\n const groupBounds = animationParameters.group ? animationParameters.group.AABBBounds : null;\n const groupWidth = groupBounds.width() ?? animationParameters.width;\n const groupHeight = groupBounds.height() ?? animationParameters.height;\n const changedX = (orient === 'negative' ? groupWidth : 0) + offset;\n const changedY = (orient === 'negative' ? groupHeight : 0) + offset;\n const point = isFunction(pointOpt)\n ? pointOpt.call(null, graphic.context?.data?.[0], graphic, animationParameters)\n : pointOpt;\n const fromX = point && isValidNumber(point.x) ? point.x : changedX;\n const fromY = point && isValidNumber(point.y) ? point.y : changedY;\n\n switch (direction) {\n case 'x':\n return {\n from: { x: graphic.getGraphicAttribute('x') },\n to: { x: fromX }\n };\n case 'y':\n return {\n from: { y: graphic.getGraphicAttribute('y') },\n to: { y: fromY }\n };\n case 'xy':\n default:\n return {\n from: {\n x: graphic.getGraphicAttribute('x'),\n y: graphic.getGraphicAttribute('y')\n },\n to: { x: fromX, y: fromY }\n };\n }\n};\n\nexport class MoveBase extends ACustomAnimate<Record<string, number>> {\n declare valid: boolean;\n\n constructor(from: null, to: null, duration: number, easing: EasingType, params?: any) {\n super(from, to, duration, easing, params);\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n const attribute: Record<string, any> = this.target.attribute;\n this.propKeys.forEach(key => {\n attribute[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;\n });\n this.target.addUpdatePositionTag();\n this.target.addUpdateShapeAndBoundsTag();\n }\n}\n\n/**\n * 增长渐入\n */\nexport class MoveIn extends MoveBase {\n onBind(): void {\n super.onBind();\n const { from, to } = moveIn(this.target, this.params.options, this.params);\n this.props = to;\n this.propKeys = Object.keys(to).filter(key => (to as any)[key] != null);\n this.from = from;\n this.to = to;\n\n // 用于入场的时候设置属性(因为有动画的时候VChart不会再设置属性了)\n const finalAttribute = this.target.getFinalAttribute();\n if (finalAttribute) {\n this.target.setAttributes(finalAttribute);\n }\n\n if (this.params.controlOptions?.immediatelyApply !== false) {\n this.target.setAttributes(from);\n }\n }\n}\n\nexport class MoveOut extends MoveBase {\n onBind(): void {\n super.onBind();\n const { from, to } = moveOut(this.target, this.params.options, this.params);\n this.props = to;\n this.propKeys = Object.keys(to).filter(key => (to as any)[key] != null);\n this.from = from;\n this.to = to;\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visactor/vrender-animate",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6-alpha.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "cjs/index.js",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
],
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@visactor/vutils": "1.0.6",
|
|
16
|
-
"@visactor/vrender-core": "1.0.
|
|
16
|
+
"@visactor/vrender-core": "1.0.6-alpha.0"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@rushstack/eslint-patch": "~1.1.4",
|