@visactor/vgrammar-core 0.7.3 → 0.7.4-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/graph/animation/animation/update.js +2 -4
- package/cjs/graph/animation/animation/update.js.map +1 -1
- package/cjs/graph/animation/attribute.d.ts +1 -0
- package/cjs/graph/animation/attribute.js +11 -1
- package/cjs/graph/animation/attribute.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/es/graph/animation/animation/update.js +1 -5
- package/es/graph/animation/animation/update.js.map +1 -1
- package/es/graph/animation/attribute.d.ts +1 -0
- package/es/graph/animation/attribute.js +12 -2
- package/es/graph/animation/attribute.js.map +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -4,11 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
}), exports.update = void 0;
|
|
6
6
|
|
|
7
|
-
const vutils_1 = require("@visactor/vutils"), vgrammar_util_1 = require("@visactor/vgrammar-util"),
|
|
7
|
+
const vutils_1 = require("@visactor/vutils"), vgrammar_util_1 = require("@visactor/vgrammar-util"), update = (element, options, animationParameters) => {
|
|
8
8
|
const from = Object.assign({}, element.getPrevGraphicAttributes()), to = Object.assign({}, element.getNextGraphicAttributes());
|
|
9
|
-
return
|
|
10
|
-
delete from[key], delete to[key];
|
|
11
|
-
})), (0, vutils_1.array)(null == options ? void 0 : options.excludeChannels).forEach((key => {
|
|
9
|
+
return (0, vutils_1.array)(null == options ? void 0 : options.excludeChannels).forEach((key => {
|
|
12
10
|
delete from[key], delete to[key];
|
|
13
11
|
})), Object.keys(to).forEach((key => {
|
|
14
12
|
(0, vgrammar_util_1.isEqual)(key, from, to) && (delete from[key], delete to[key]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graph/animation/animation/update.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AACzC,2DAAkD;
|
|
1
|
+
{"version":3,"sources":["../src/graph/animation/animation/update.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AACzC,2DAAkD;AAQ3C,MAAM,MAAM,GAA4B,CAC7C,OAAiB,EACjB,OAAgC,EAChC,mBAAyC,EACzC,EAAE;IACF,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,wBAAwB,EAAE,CAAC,CAAC;IACnE,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,wBAAwB,EAAE,CAAC,CAAC;IACjE,IAAA,cAAK,EAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,eAAe,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QAC5C,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;QACjB,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC;IACjB,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QAC5B,IAAI,IAAA,uBAAO,EAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE;YAC1B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;YACjB,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC;SAChB;IACH,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;AACtB,CAAC,CAAC;AAlBW,QAAA,MAAM,UAkBjB","file":"update.js","sourcesContent":["import { array } from '@visactor/vutils';\nimport { isEqual } from '@visactor/vgrammar-util';\nimport type { IElement } from '../../../types';\nimport type { IAnimationParameters, TypeAnimation } from '../../../types/animate';\n\nexport interface IUpdateAnimationOptions {\n excludeChannels: string[];\n}\n\nexport const update: TypeAnimation<IElement> = (\n element: IElement,\n options: IUpdateAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const from = Object.assign({}, element.getPrevGraphicAttributes());\n const to = Object.assign({}, element.getNextGraphicAttributes());\n array(options?.excludeChannels).forEach(key => {\n delete from[key];\n delete to[key];\n });\n Object.keys(to).forEach(key => {\n if (isEqual(key, from, to)) {\n delete from[key];\n delete to[key];\n }\n });\n return { from, to };\n};\n"]}
|
|
@@ -23,5 +23,6 @@ export declare class AttributeAnimate extends ACustomAnimate<any> {
|
|
|
23
23
|
onBind(): void;
|
|
24
24
|
onStart(): void;
|
|
25
25
|
onEnd(): void;
|
|
26
|
+
update(end: boolean, ratio: number, out: Record<string, any>): void;
|
|
26
27
|
onUpdate(end: boolean, ratio: number, out: Record<string, any>): void;
|
|
27
28
|
}
|
|
@@ -99,9 +99,12 @@ class AttributeAnimate extends vrender_1.ACustomAnimate {
|
|
|
99
99
|
this.from = null !== (_a = this.from) && void 0 !== _a ? _a : {}, this.to = null !== (_b = this.to) && void 0 !== _b ? _b : {};
|
|
100
100
|
}
|
|
101
101
|
onStart() {
|
|
102
|
+
var _a;
|
|
103
|
+
const excludedChannelMap = null !== (_a = this.target.constructor.NOWORK_ANIMATE_ATTR) && void 0 !== _a ? _a : vrender_1.NOWORK_ANIMATE_ATTR, excludedChannels = Object.keys(excludedChannelMap).filter((channel => 0 !== excludedChannelMap[channel]));
|
|
104
|
+
this.subAnimate.animate.preventAttrs(excludedChannels);
|
|
102
105
|
const from = Object.assign({}, this.from), to = Object.assign({}, this.to);
|
|
103
106
|
Object.keys(to).forEach((k => {
|
|
104
|
-
(0, vutils_1.isNil)(from[k]) && (from[k] = this.target.getComputedAttribute(k));
|
|
107
|
+
excludedChannels.includes(k) ? (from[k] = to[k], this.from[k] = to[k]) : (0, vutils_1.isNil)(from[k]) && (from[k] = this.target.getComputedAttribute(k));
|
|
105
108
|
})), this.target.setAttributes(from, !1, {
|
|
106
109
|
type: vrender_1.AttributeUpdateType.ANIMATE_UPDATE,
|
|
107
110
|
animationState: {
|
|
@@ -115,6 +118,13 @@ class AttributeAnimate extends vrender_1.ACustomAnimate {
|
|
|
115
118
|
type: vrender_1.AttributeUpdateType.ANIMATE_END
|
|
116
119
|
});
|
|
117
120
|
}
|
|
121
|
+
update(end, ratio, out) {
|
|
122
|
+
0 === this.updateCount && this.onFirstRun(), this.updateCount += 1;
|
|
123
|
+
const lastProps = this.step.getLastProps();
|
|
124
|
+
Object.keys(lastProps).forEach((key => {
|
|
125
|
+
this.subAnimate.animate.validAttr(key) && (out[key] = lastProps[key]);
|
|
126
|
+
})), this.onUpdate(end, ratio, out), end && this.onEnd();
|
|
127
|
+
}
|
|
118
128
|
onUpdate(end, ratio, out) {
|
|
119
129
|
this.target.stepInterpolate(this.subAnimate, this.subAnimate.animate, out, this.step, ratio, end, this._toAttribute, this._fromAttribute);
|
|
120
130
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graph/animation/attribute.ts"],"names":[],"mappings":";;;AAEA,+CAAwE;AACxE,6CAAiF;AASjF,mDAA6D;AAC7D,gDAA6C;AAE7C,MAAM,4BAA4B,GAAG,CAAC,UAAiC,EAAE,OAAiB,EAAyB,EAAE;IACnH,IAAI,CAAC,UAAU,EAAE;QACf,OAAO,IAAI,CAAC;KACb;IAED,IAAI,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,IAAI,EAAE;QACpB,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;QAC7B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;YAClC,IAAI,IAAA,cAAK,EAAC,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE;gBACxB,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;aACtB;QACH,CAAC,CAAC,CAAC;QACH,MAAM,aAAa,GAAG,IAAA,8BAAoB,EAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,I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,eAAe,CACzB,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,UAAU,CAAC,OAAO,EACvB,GAAG,EACH,IAAI,CAAC,IAAI,EACT,KAAK,EACL,GAAG,EACH,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,cAAc,CACpB,CAAC;IACJ,CAAC;CACF;AArDD,4CAqDC","file":"attribute.js","sourcesContent":["import type { EasingType, IGraphic } from '@visactor/vrender';\n// eslint-disable-next-line no-duplicate-imports\nimport { ACustomAnimate, AttributeUpdateType } from '@visactor/vrender';\nimport { isArray, isFunction, isNil, isObject, isValid } from '@visactor/vutils';\nimport type {\n IAnimationChannelInterpolator,\n IAnimationEffect,\n IAnimationParameters,\n IElement,\n IGlyphElement,\n IParsedAnimationAttrs\n} from '../../types';\nimport { isValidPointsChannel } from '../attributes/helpers';\nimport { Factory } from '../../core/factory';\n\nconst transformAnimationAttributes = (attributes: IParsedAnimationAttrs, element: IElement): IParsedAnimationAttrs => {\n if (!attributes) {\n return null;\n }\n\n if (attributes?.from) {\n const from = attributes.from;\n Object.keys(from).forEach(channel => {\n if (isNil(from[channel])) {\n delete from[channel];\n }\n });\n const computePoints = isValidPointsChannel(Object.keys(from), element.mark.markType) && !isValid(from.segments);\n if (computePoints) {\n const items = element.items.map(item => Object.assign({}, item, { nextAttrs: from }));\n attributes.from = element.transformElementItems(items, element.mark.markType, computePoints);\n }\n }\n if (attributes?.to) {\n const to = attributes.to;\n Object.keys(to).forEach(channel => {\n if (isNil(to[channel])) {\n delete to[channel];\n }\n });\n const computePoints = isValidPointsChannel(Object.keys(to), element.mark.markType) && !isValid(to.segments);\n if (computePoints) {\n const items = element.items.map(item => Object.assign({}, item, { nextAttrs: to }));\n attributes.to = element.transformElementItems(items, element.mark.markType, computePoints);\n }\n }\n\n return attributes;\n};\n\nexport function typeAnimationAttributes(\n element: IElement,\n effect: IAnimationEffect,\n animationParameters: IAnimationParameters,\n parameters: any\n): IParsedAnimationAttrs {\n // const parameters =\n const options = isFunction(effect.options)\n ? effect.options.call(null, element.getDatum(), element, parameters)\n : effect.options;\n if (!effect.type || !Factory.getAnimationType(effect.type)) {\n return null;\n }\n const attributes = Factory.getAnimationType(effect.type)(element as IGlyphElement, options, animationParameters);\n return transformAnimationAttributes(attributes, element);\n}\n\nconst parseChannelValue = (\n element: IElement,\n channel: string,\n channelValue: any,\n animationParameters: IAnimationParameters,\n parameters: any\n) => {\n return isFunction(channelValue) ? channelValue(element.getDatum(), element, parameters) : channelValue;\n};\n\nexport function channelAnimationAttributes(\n element: IElement,\n effect: IAnimationEffect,\n animationParameters: IAnimationParameters,\n parameters: any\n): IParsedAnimationAttrs {\n const channel = effect.channel;\n let attributes: IParsedAnimationAttrs = null;\n\n if (isArray(channel)) {\n attributes = channel.reduce(\n (res, key) => {\n res.from[key] = element.getGraphicAttribute(key, true);\n res.to[key] = element.getGraphicAttribute(key, false);\n return res;\n },\n { from: {}, to: {} }\n );\n } else if (isObject(channel)) {\n attributes = Object.keys(channel).reduce(\n (res, key) => {\n const hasFrom = !isNil(channel[key]?.from);\n const hasTo = !isNil(channel[key]?.to);\n\n if (hasFrom || hasTo) {\n res.from[key] = hasFrom\n ? parseChannelValue(element, key, channel[key].from, animationParameters, parameters)\n : undefined;\n res.to[key] = hasTo\n ? parseChannelValue(element, key, channel[key].to, animationParameters, parameters)\n : element.getGraphicAttribute(key, false);\n }\n\n return res;\n },\n { from: {}, to: {} }\n );\n }\n\n return transformAnimationAttributes(attributes, element);\n}\n\nexport class CustomInterpolator extends ACustomAnimate<any> {\n private _element: IElement;\n private _interpolator?: IAnimationChannelInterpolator;\n\n constructor(\n from: any,\n to: any,\n duration: number,\n easing: EasingType,\n params: { interpolator: IAnimationChannelInterpolator; element: IElement; parameters?: any }\n ) {\n super(from, to, duration, easing, params);\n this._interpolator = params?.interpolator;\n this._element = params?.element;\n }\n\n onBind() {\n this.from = this.from ?? {};\n this.to = this.to ?? {};\n }\n\n getEndProps(): void | Record<string, any> {\n return this.to;\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n if (!this._interpolator || !this._element) {\n return;\n }\n this._interpolator.call(\n this,\n ratio,\n this.from,\n this.to,\n out,\n this._element.getDatum(),\n this._element,\n this.params.parameters\n );\n }\n}\n\nexport class AttributeAnimate extends ACustomAnimate<any> {\n declare target: IGraphic;\n\n private _fromAttribute: any;\n private _toAttribute: any;\n\n getEndProps(): Record<string, any> {\n return this.to;\n }\n\n onBind() {\n this.from = this.from ?? {};\n this.to = this.to ?? {};\n }\n\n onStart(): void {\n const from = Object.assign({}, this.from);\n const to = Object.assign({}, this.to);\n Object.keys(to).forEach(k => {\n if (isNil(from[k])) {\n from[k] = this.target.getComputedAttribute(k);\n }\n // if (this.to[k] === from[k]) {\n // delete from[k];\n // }\n });\n this.target.setAttributes(from, false, {\n type: AttributeUpdateType.ANIMATE_UPDATE,\n animationState: { ratio: 0, end: false }\n });\n\n this._fromAttribute = from;\n this._toAttribute = to;\n }\n\n onEnd(): void {\n this.target.setAttributes(this._toAttribute, false, {\n type: AttributeUpdateType.ANIMATE_END\n });\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n this.target.stepInterpolate(\n this.subAnimate,\n this.subAnimate.animate,\n out,\n this.step,\n ratio,\n end,\n this._toAttribute,\n this._fromAttribute\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/graph/animation/attribute.ts"],"names":[],"mappings":";;;AAEA,+CAA6F;AAC7F,6CAAiF;AASjF,mDAA6D;AAC7D,gDAA6C;AAE7C,MAAM,4BAA4B,GAAG,CAAC,UAAiC,EAAE,OAAiB,EAAyB,EAAE;IACnH,IAAI,CAAC,UAAU,EAAE;QACf,OAAO,IAAI,CAAC;KACb;IAED,IAAI,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,IAAI,EAAE;QACpB,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;QAC7B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CA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3B;QACH,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;QAC/B,IAAI,GAAG,EAAE;YACP,IAAI,CAAC,KAAK,EAAE,CAAC;SACd;IACH,CAAC;IAED,QAAQ,CAAC,GAAY,EAAE,KAAa,EAAE,GAAwB;QAC5D,IAAI,CAAC,MAAM,CAAC,eAAe,CACzB,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,UAAU,CAAC,OAAO,EACvB,GAAG,EACH,IAAI,CAAC,IAAI,EACT,KAAK,EACL,GAAG,EACH,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,cAAc,CACpB,CAAC;IACJ,CAAC;CACF;AAhFD,4CAgFC","file":"attribute.js","sourcesContent":["import type { EasingType, IGraphic } from '@visactor/vrender';\n// eslint-disable-next-line no-duplicate-imports\nimport { ACustomAnimate, AttributeUpdateType, NOWORK_ANIMATE_ATTR } from '@visactor/vrender';\nimport { isArray, isFunction, isNil, isObject, isValid } from '@visactor/vutils';\nimport type {\n IAnimationChannelInterpolator,\n IAnimationEffect,\n IAnimationParameters,\n IElement,\n IGlyphElement,\n IParsedAnimationAttrs\n} from '../../types';\nimport { isValidPointsChannel } from '../attributes/helpers';\nimport { Factory } from '../../core/factory';\n\nconst transformAnimationAttributes = (attributes: IParsedAnimationAttrs, element: IElement): IParsedAnimationAttrs => {\n if (!attributes) {\n return null;\n }\n\n if (attributes?.from) {\n const from = attributes.from;\n Object.keys(from).forEach(channel => {\n if (isNil(from[channel])) {\n delete from[channel];\n }\n });\n const computePoints = isValidPointsChannel(Object.keys(from), element.mark.markType) && !isValid(from.segments);\n if (computePoints) {\n const items = element.items.map(item => Object.assign({}, item, { nextAttrs: from }));\n attributes.from = element.transformElementItems(items, element.mark.markType, computePoints);\n }\n }\n if (attributes?.to) {\n const to = attributes.to;\n Object.keys(to).forEach(channel => {\n if (isNil(to[channel])) {\n delete to[channel];\n }\n });\n const computePoints = isValidPointsChannel(Object.keys(to), element.mark.markType) && !isValid(to.segments);\n if (computePoints) {\n const items = element.items.map(item => Object.assign({}, item, { nextAttrs: to }));\n attributes.to = element.transformElementItems(items, element.mark.markType, computePoints);\n }\n }\n\n return attributes;\n};\n\nexport function typeAnimationAttributes(\n element: IElement,\n effect: IAnimationEffect,\n animationParameters: IAnimationParameters,\n parameters: any\n): IParsedAnimationAttrs {\n // const parameters =\n const options = isFunction(effect.options)\n ? effect.options.call(null, element.getDatum(), element, parameters)\n : effect.options;\n if (!effect.type || !Factory.getAnimationType(effect.type)) {\n return null;\n }\n const attributes = Factory.getAnimationType(effect.type)(element as IGlyphElement, options, animationParameters);\n return transformAnimationAttributes(attributes, element);\n}\n\nconst parseChannelValue = (\n element: IElement,\n channel: string,\n channelValue: any,\n animationParameters: IAnimationParameters,\n parameters: any\n) => {\n return isFunction(channelValue) ? channelValue(element.getDatum(), element, parameters) : channelValue;\n};\n\nexport function channelAnimationAttributes(\n element: IElement,\n effect: IAnimationEffect,\n animationParameters: IAnimationParameters,\n parameters: any\n): IParsedAnimationAttrs {\n const channel = effect.channel;\n let attributes: IParsedAnimationAttrs = null;\n\n if (isArray(channel)) {\n attributes = channel.reduce(\n (res, key) => {\n res.from[key] = element.getGraphicAttribute(key, true);\n res.to[key] = element.getGraphicAttribute(key, false);\n return res;\n },\n { from: {}, to: {} }\n );\n } else if (isObject(channel)) {\n attributes = Object.keys(channel).reduce(\n (res, key) => {\n const hasFrom = !isNil(channel[key]?.from);\n const hasTo = !isNil(channel[key]?.to);\n\n if (hasFrom || hasTo) {\n res.from[key] = hasFrom\n ? parseChannelValue(element, key, channel[key].from, animationParameters, parameters)\n : undefined;\n res.to[key] = hasTo\n ? parseChannelValue(element, key, channel[key].to, animationParameters, parameters)\n : element.getGraphicAttribute(key, false);\n }\n\n return res;\n },\n { from: {}, to: {} }\n );\n }\n\n return transformAnimationAttributes(attributes, element);\n}\n\nexport class CustomInterpolator extends ACustomAnimate<any> {\n private _element: IElement;\n private _interpolator?: IAnimationChannelInterpolator;\n\n constructor(\n from: any,\n to: any,\n duration: number,\n easing: EasingType,\n params: { interpolator: IAnimationChannelInterpolator; element: IElement; parameters?: any }\n ) {\n super(from, to, duration, easing, params);\n this._interpolator = params?.interpolator;\n this._element = params?.element;\n }\n\n onBind() {\n this.from = this.from ?? {};\n this.to = this.to ?? {};\n }\n\n getEndProps(): void | Record<string, any> {\n return this.to;\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n if (!this._interpolator || !this._element) {\n return;\n }\n this._interpolator.call(\n this,\n ratio,\n this.from,\n this.to,\n out,\n this._element.getDatum(),\n this._element,\n this.params.parameters\n );\n }\n}\n\nexport class AttributeAnimate extends ACustomAnimate<any> {\n declare target: IGraphic;\n\n private _fromAttribute: any;\n private _toAttribute: any;\n\n getEndProps(): Record<string, any> {\n return this.to;\n }\n\n onBind() {\n this.from = this.from ?? {};\n this.to = this.to ?? {};\n }\n\n onStart(): void {\n const excludedChannelMap = (this.target.constructor as any).NOWORK_ANIMATE_ATTR ?? NOWORK_ANIMATE_ATTR;\n const excludedChannels = Object.keys(excludedChannelMap).filter(channel => excludedChannelMap[channel] !== 0);\n this.subAnimate.animate.preventAttrs(excludedChannels);\n\n const from = Object.assign({}, this.from);\n const to = Object.assign({}, this.to);\n Object.keys(to).forEach(k => {\n if (excludedChannels.includes(k)) {\n from[k] = to[k];\n this.from[k] = to[k];\n } else if (isNil(from[k])) {\n from[k] = this.target.getComputedAttribute(k);\n }\n // if (this.to[k] === from[k]) {\n // delete from[k];\n // }\n });\n\n this.target.setAttributes(from, false, {\n type: AttributeUpdateType.ANIMATE_UPDATE,\n animationState: { ratio: 0, end: false }\n });\n\n this._fromAttribute = from;\n this._toAttribute = to;\n }\n\n onEnd(): void {\n this.target.setAttributes(this._toAttribute, false, {\n type: AttributeUpdateType.ANIMATE_END\n });\n }\n\n update(end: boolean, ratio: number, out: Record<string, any>): void {\n if (this.updateCount === 0) {\n this.onFirstRun();\n }\n this.updateCount += 1;\n\n // Hack: waiting for canopus to remove invalid key when updating\n const lastProps = this.step.getLastProps();\n Object.keys(lastProps).forEach(key => {\n if (this.subAnimate.animate.validAttr(key)) {\n out[key] = lastProps[key];\n }\n });\n this.onUpdate(end, ratio, out);\n if (end) {\n this.onEnd();\n }\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n this.target.stepInterpolate(\n this.subAnimate,\n this.subAnimate.animate,\n out,\n this.step,\n ratio,\n end,\n this._toAttribute,\n this._fromAttribute\n );\n }\n}\n"]}
|
package/cjs/index.d.ts
CHANGED
package/cjs/index.js
CHANGED
|
@@ -18,7 +18,7 @@ var __createBinding = this && this.__createBinding || (Object.create ? function(
|
|
|
18
18
|
Object.defineProperty(exports, "__esModule", {
|
|
19
19
|
value: !0
|
|
20
20
|
}), exports.ThemeManager = exports.SIGNAL_VIEW_BOX = exports.SIGNAL_WIDTH = exports.SIGNAL_VIEW_WIDTH = exports.SIGNAL_VIEW_HEIGHT = exports.SIGNAL_PADDING = exports.SIGNAL_HEIGHT = exports.SIGNAL_AUTOFIT = exports.Factory = exports.GrammarBase = exports.invokeFunctionType = exports.parseFunctionType = exports.View = exports.version = void 0,
|
|
21
|
-
exports.version = "0.7.
|
|
21
|
+
exports.version = "0.7.4-alpha.0", __exportStar(require("./graph"), exports);
|
|
22
22
|
|
|
23
23
|
var view_1 = require("./view");
|
|
24
24
|
|
package/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACa,QAAA,OAAO,GAAG,
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACa,QAAA,OAAO,GAAG,eAAe,CAAC;AAEvC,0CAAwB;AAExB,+BAA8B;AAArB,4FAAA,IAAI,OAAA;AACb,qCAAqE;AAA5D,yGAAA,iBAAiB,OAAA;AAAE,0GAAA,kBAAkB,OAAA;AAC9C,oDAAkD;AAAzC,2GAAA,WAAW,OAAA;AACpB,8CAA4B;AAC5B,0CAAwB;AACxB,0CAAyC;AAAhC,kGAAA,OAAO,OAAA;AAChB,8CAQ0B;AAPxB,2GAAA,cAAc,OAAA;AACd,0GAAA,aAAa,OAAA;AACb,2GAAA,cAAc,OAAA;AACd,+GAAA,kBAAkB,OAAA;AAClB,8GAAA,iBAAiB,OAAA;AACjB,yGAAA,YAAY,OAAA;AACZ,4GAAA,eAAe,OAAA;AAGjB,uDAAqD;AAA5C,6GAAA,YAAY,OAAA;AAErB,0CAAwB;AACxB,8CAA4B;AAC5B,+CAA6B;AAC7B,8DAA4C","file":"index.js","sourcesContent":["// -- Exports -----\nexport const version = \"0.7.4-alpha.0\";\n\nexport * from './graph';\n\nexport { View } from './view';\nexport { parseFunctionType, invokeFunctionType } from './parse/util';\nexport { GrammarBase } from './view/grammar-base';\nexport * from './util/text';\nexport * from './types';\nexport { Factory } from './core/factory';\nexport {\n SIGNAL_AUTOFIT,\n SIGNAL_HEIGHT,\n SIGNAL_PADDING,\n SIGNAL_VIEW_HEIGHT,\n SIGNAL_VIEW_WIDTH,\n SIGNAL_WIDTH,\n SIGNAL_VIEW_BOX\n} from './view/constants';\n\nexport { ThemeManager } from './theme/theme-manager';\n\nexport * from './glyph';\nexport * from './component';\nexport * from './transforms';\nexport * from './graph/animation/animation';\n"]}
|
|
@@ -2,13 +2,9 @@ import { array } from "@visactor/vutils";
|
|
|
2
2
|
|
|
3
3
|
import { isEqual } from "@visactor/vgrammar-util";
|
|
4
4
|
|
|
5
|
-
const defaultExcludedChannels = [ "visible", "path", "text", "lineWidth", "textBaseline", "textAlign" ];
|
|
6
|
-
|
|
7
5
|
export const update = (element, options, animationParameters) => {
|
|
8
6
|
const from = Object.assign({}, element.getPrevGraphicAttributes()), to = Object.assign({}, element.getNextGraphicAttributes());
|
|
9
|
-
return
|
|
10
|
-
delete from[key], delete to[key];
|
|
11
|
-
})), array(null == options ? void 0 : options.excludeChannels).forEach((key => {
|
|
7
|
+
return array(null == options ? void 0 : options.excludeChannels).forEach((key => {
|
|
12
8
|
delete from[key], delete to[key];
|
|
13
9
|
})), Object.keys(to).forEach((key => {
|
|
14
10
|
isEqual(key, from, to) && (delete from[key], delete to[key]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graph/animation/animation/update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"sources":["../src/graph/animation/animation/update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAQlD,MAAM,CAAC,MAAM,MAAM,GAA4B,CAC7C,OAAiB,EACjB,OAAgC,EAChC,mBAAyC,EACzC,EAAE;IACF,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,wBAAwB,EAAE,CAAC,CAAC;IACnE,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,wBAAwB,EAAE,CAAC,CAAC;IACjE,KAAK,CAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,eAAe,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QAC5C,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;QACjB,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC;IACjB,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QAC5B,IAAI,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE;YAC1B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;YACjB,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC;SAChB;IACH,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;AACtB,CAAC,CAAC","file":"update.js","sourcesContent":["import { array } from '@visactor/vutils';\nimport { isEqual } from '@visactor/vgrammar-util';\nimport type { IElement } from '../../../types';\nimport type { IAnimationParameters, TypeAnimation } from '../../../types/animate';\n\nexport interface IUpdateAnimationOptions {\n excludeChannels: string[];\n}\n\nexport const update: TypeAnimation<IElement> = (\n element: IElement,\n options: IUpdateAnimationOptions,\n animationParameters: IAnimationParameters\n) => {\n const from = Object.assign({}, element.getPrevGraphicAttributes());\n const to = Object.assign({}, element.getNextGraphicAttributes());\n array(options?.excludeChannels).forEach(key => {\n delete from[key];\n delete to[key];\n });\n Object.keys(to).forEach(key => {\n if (isEqual(key, from, to)) {\n delete from[key];\n delete to[key];\n }\n });\n return { from, to };\n};\n"]}
|
|
@@ -23,5 +23,6 @@ export declare class AttributeAnimate extends ACustomAnimate<any> {
|
|
|
23
23
|
onBind(): void;
|
|
24
24
|
onStart(): void;
|
|
25
25
|
onEnd(): void;
|
|
26
|
+
update(end: boolean, ratio: number, out: Record<string, any>): void;
|
|
26
27
|
onUpdate(end: boolean, ratio: number, out: Record<string, any>): void;
|
|
27
28
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ACustomAnimate, AttributeUpdateType } from "@visactor/vrender";
|
|
1
|
+
import { ACustomAnimate, AttributeUpdateType, NOWORK_ANIMATE_ATTR } from "@visactor/vrender";
|
|
2
2
|
|
|
3
3
|
import { isArray, isFunction, isNil, isObject, isValid } from "@visactor/vutils";
|
|
4
4
|
|
|
@@ -91,9 +91,12 @@ export class AttributeAnimate extends ACustomAnimate {
|
|
|
91
91
|
this.from = null !== (_a = this.from) && void 0 !== _a ? _a : {}, this.to = null !== (_b = this.to) && void 0 !== _b ? _b : {};
|
|
92
92
|
}
|
|
93
93
|
onStart() {
|
|
94
|
+
var _a;
|
|
95
|
+
const excludedChannelMap = null !== (_a = this.target.constructor.NOWORK_ANIMATE_ATTR) && void 0 !== _a ? _a : NOWORK_ANIMATE_ATTR, excludedChannels = Object.keys(excludedChannelMap).filter((channel => 0 !== excludedChannelMap[channel]));
|
|
96
|
+
this.subAnimate.animate.preventAttrs(excludedChannels);
|
|
94
97
|
const from = Object.assign({}, this.from), to = Object.assign({}, this.to);
|
|
95
98
|
Object.keys(to).forEach((k => {
|
|
96
|
-
isNil(from[k]) && (from[k] = this.target.getComputedAttribute(k));
|
|
99
|
+
excludedChannels.includes(k) ? (from[k] = to[k], this.from[k] = to[k]) : isNil(from[k]) && (from[k] = this.target.getComputedAttribute(k));
|
|
97
100
|
})), this.target.setAttributes(from, !1, {
|
|
98
101
|
type: AttributeUpdateType.ANIMATE_UPDATE,
|
|
99
102
|
animationState: {
|
|
@@ -107,6 +110,13 @@ export class AttributeAnimate extends ACustomAnimate {
|
|
|
107
110
|
type: AttributeUpdateType.ANIMATE_END
|
|
108
111
|
});
|
|
109
112
|
}
|
|
113
|
+
update(end, ratio, out) {
|
|
114
|
+
0 === this.updateCount && this.onFirstRun(), this.updateCount += 1;
|
|
115
|
+
const lastProps = this.step.getLastProps();
|
|
116
|
+
Object.keys(lastProps).forEach((key => {
|
|
117
|
+
this.subAnimate.animate.validAttr(key) && (out[key] = lastProps[key]);
|
|
118
|
+
})), this.onUpdate(end, ratio, out), end && this.onEnd();
|
|
119
|
+
}
|
|
110
120
|
onUpdate(end, ratio, out) {
|
|
111
121
|
this.target.stepInterpolate(this.subAnimate, this.subAnimate.animate, out, this.step, ratio, end, this._toAttribute, this._fromAttribute);
|
|
112
122
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graph/animation/attribute.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,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AAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;aAC/C;QAIH,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE,KAAK,EAAE;YACrC,IAAI,EAAE,mBAAmB,CAAC,cAAc;YACxC,cAAc,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE;SACzC,CAAC,CAAC;QAEH,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC3B,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;IACzB,CAAC;IAED,KAAK;QACH,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,YAAY,EAAE,KAAK,EAAE;YAClD,IAAI,EAAE,mBAAmB,CAAC,WAAW;SACtC,CAAC,CAAC;IACL,CAAC;IAED,QAAQ,CAAC,GAAY,EAAE,KAAa,EAAE,GAAwB;QAC5D,IAAI,CAAC,MAAM,CAAC,eAAe,CACzB,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,UAAU,CAAC,OAAO,EACvB,GAAG,EACH,IAAI,CAAC,IAAI,EACT,KAAK,EACL,GAAG,EACH,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,cAAc,CACpB,CAAC;IACJ,CAAC;CACF","file":"attribute.js","sourcesContent":["import type { EasingType, IGraphic } from '@visactor/vrender';\n// eslint-disable-next-line no-duplicate-imports\nimport { ACustomAnimate, AttributeUpdateType } from '@visactor/vrender';\nimport { isArray, isFunction, isNil, isObject, isValid } from '@visactor/vutils';\nimport type {\n IAnimationChannelInterpolator,\n IAnimationEffect,\n IAnimationParameters,\n IElement,\n IGlyphElement,\n IParsedAnimationAttrs\n} from '../../types';\nimport { isValidPointsChannel } from '../attributes/helpers';\nimport { Factory } from '../../core/factory';\n\nconst transformAnimationAttributes = (attributes: IParsedAnimationAttrs, element: IElement): IParsedAnimationAttrs => {\n if (!attributes) {\n return null;\n }\n\n if (attributes?.from) {\n const from = attributes.from;\n Object.keys(from).forEach(channel => {\n if (isNil(from[channel])) {\n delete from[channel];\n }\n });\n const computePoints = isValidPointsChannel(Object.keys(from), element.mark.markType) && !isValid(from.segments);\n if (computePoints) {\n const items = element.items.map(item => Object.assign({}, item, { nextAttrs: from }));\n attributes.from = element.transformElementItems(items, element.mark.markType, computePoints);\n }\n }\n if (attributes?.to) {\n const to = attributes.to;\n Object.keys(to).forEach(channel => {\n if (isNil(to[channel])) {\n delete to[channel];\n }\n });\n const computePoints = isValidPointsChannel(Object.keys(to), element.mark.markType) && !isValid(to.segments);\n if (computePoints) {\n const items = element.items.map(item => Object.assign({}, item, { nextAttrs: to }));\n attributes.to = element.transformElementItems(items, element.mark.markType, computePoints);\n }\n }\n\n return attributes;\n};\n\nexport function typeAnimationAttributes(\n element: IElement,\n effect: IAnimationEffect,\n animationParameters: IAnimationParameters,\n parameters: any\n): IParsedAnimationAttrs {\n // const parameters =\n const options = isFunction(effect.options)\n ? effect.options.call(null, element.getDatum(), element, parameters)\n : effect.options;\n if (!effect.type || !Factory.getAnimationType(effect.type)) {\n return null;\n }\n const attributes = Factory.getAnimationType(effect.type)(element as IGlyphElement, options, animationParameters);\n return transformAnimationAttributes(attributes, element);\n}\n\nconst parseChannelValue = (\n element: IElement,\n channel: string,\n channelValue: any,\n animationParameters: IAnimationParameters,\n parameters: any\n) => {\n return isFunction(channelValue) ? channelValue(element.getDatum(), element, parameters) : channelValue;\n};\n\nexport function channelAnimationAttributes(\n element: IElement,\n effect: IAnimationEffect,\n animationParameters: IAnimationParameters,\n parameters: any\n): IParsedAnimationAttrs {\n const channel = effect.channel;\n let attributes: IParsedAnimationAttrs = null;\n\n if (isArray(channel)) {\n attributes = channel.reduce(\n (res, key) => {\n res.from[key] = element.getGraphicAttribute(key, true);\n res.to[key] = element.getGraphicAttribute(key, false);\n return res;\n },\n { from: {}, to: {} }\n );\n } else if (isObject(channel)) {\n attributes = Object.keys(channel).reduce(\n (res, key) => {\n const hasFrom = !isNil(channel[key]?.from);\n const hasTo = !isNil(channel[key]?.to);\n\n if (hasFrom || hasTo) {\n res.from[key] = hasFrom\n ? parseChannelValue(element, key, channel[key].from, animationParameters, parameters)\n : undefined;\n res.to[key] = hasTo\n ? parseChannelValue(element, key, channel[key].to, animationParameters, parameters)\n : element.getGraphicAttribute(key, false);\n }\n\n return res;\n },\n { from: {}, to: {} }\n );\n }\n\n return transformAnimationAttributes(attributes, element);\n}\n\nexport class CustomInterpolator extends ACustomAnimate<any> {\n private _element: IElement;\n private _interpolator?: IAnimationChannelInterpolator;\n\n constructor(\n from: any,\n to: any,\n duration: number,\n easing: EasingType,\n params: { interpolator: IAnimationChannelInterpolator; element: IElement; parameters?: any }\n ) {\n super(from, to, duration, easing, params);\n this._interpolator = params?.interpolator;\n this._element = params?.element;\n }\n\n onBind() {\n this.from = this.from ?? {};\n this.to = this.to ?? {};\n }\n\n getEndProps(): void | Record<string, any> {\n return this.to;\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n if (!this._interpolator || !this._element) {\n return;\n }\n this._interpolator.call(\n this,\n ratio,\n this.from,\n this.to,\n out,\n this._element.getDatum(),\n this._element,\n this.params.parameters\n );\n }\n}\n\nexport class AttributeAnimate extends ACustomAnimate<any> {\n declare target: IGraphic;\n\n private _fromAttribute: any;\n private _toAttribute: any;\n\n getEndProps(): Record<string, any> {\n return this.to;\n }\n\n onBind() {\n this.from = this.from ?? {};\n this.to = this.to ?? {};\n }\n\n onStart(): void {\n const from = Object.assign({}, this.from);\n const to = Object.assign({}, this.to);\n Object.keys(to).forEach(k => {\n if (isNil(from[k])) {\n from[k] = this.target.getComputedAttribute(k);\n }\n // if (this.to[k] === from[k]) {\n // delete from[k];\n // }\n });\n this.target.setAttributes(from, false, {\n type: AttributeUpdateType.ANIMATE_UPDATE,\n animationState: { ratio: 0, end: false }\n });\n\n this._fromAttribute = from;\n this._toAttribute = to;\n }\n\n onEnd(): void {\n this.target.setAttributes(this._toAttribute, false, {\n type: AttributeUpdateType.ANIMATE_END\n });\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n this.target.stepInterpolate(\n this.subAnimate,\n this.subAnimate.animate,\n out,\n this.step,\n ratio,\n end,\n this._toAttribute,\n this._fromAttribute\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/graph/animation/attribute.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7F,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AASjF,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,MAAM,4BAA4B,GAAG,CAAC,UAAiC,EAAE,OAAiB,EAAyB,EAAE;IACnH,IAAI,CAAC,UAAU,EAAE;QACf,OAAO,IAAI,CAAC;KACb;IAED,IAAI,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,IAAI,EAAE;QACpB,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;QAC7B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;YAClC,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE;gBACxB,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;aACtB;QACH,CAAC,CAAC,CAAC;QACH,MAAM,aAAa,GAAG,oBAAoB,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAChH,IAAI,aAAa,EAAE;YACjB,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,I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GAAG,IAAI,CAAC;QAC3B,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;IACzB,CAAC;IAED,KAAK;QACH,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,YAAY,EAAE,KAAK,EAAE;YAClD,IAAI,EAAE,mBAAmB,CAAC,WAAW;SACtC,CAAC,CAAC;IACL,CAAC;IAED,MAAM,CAAC,GAAY,EAAE,KAAa,EAAE,GAAwB;QAC1D,IAAI,IAAI,CAAC,WAAW,KAAK,CAAC,EAAE;YAC1B,IAAI,CAAC,UAAU,EAAE,CAAC;SACnB;QACD,IAAI,CAAC,WAAW,IAAI,CAAC,CAAC;QAGtB,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;QAC3C,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YACnC,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE;gBAC1C,GAAG,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;aAC3B;QACH,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;QAC/B,IAAI,GAAG,EAAE;YACP,IAAI,CAAC,KAAK,EAAE,CAAC;SACd;IACH,CAAC;IAED,QAAQ,CAAC,GAAY,EAAE,KAAa,EAAE,GAAwB;QAC5D,IAAI,CAAC,MAAM,CAAC,eAAe,CACzB,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,UAAU,CAAC,OAAO,EACvB,GAAG,EACH,IAAI,CAAC,IAAI,EACT,KAAK,EACL,GAAG,EACH,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,cAAc,CACpB,CAAC;IACJ,CAAC;CACF","file":"attribute.js","sourcesContent":["import type { EasingType, IGraphic } from '@visactor/vrender';\n// eslint-disable-next-line no-duplicate-imports\nimport { ACustomAnimate, AttributeUpdateType, NOWORK_ANIMATE_ATTR } from '@visactor/vrender';\nimport { isArray, isFunction, isNil, isObject, isValid } from '@visactor/vutils';\nimport type {\n IAnimationChannelInterpolator,\n IAnimationEffect,\n IAnimationParameters,\n IElement,\n IGlyphElement,\n IParsedAnimationAttrs\n} from '../../types';\nimport { isValidPointsChannel } from '../attributes/helpers';\nimport { Factory } from '../../core/factory';\n\nconst transformAnimationAttributes = (attributes: IParsedAnimationAttrs, element: IElement): IParsedAnimationAttrs => {\n if (!attributes) {\n return null;\n }\n\n if (attributes?.from) {\n const from = attributes.from;\n Object.keys(from).forEach(channel => {\n if (isNil(from[channel])) {\n delete from[channel];\n }\n });\n const computePoints = isValidPointsChannel(Object.keys(from), element.mark.markType) && !isValid(from.segments);\n if (computePoints) {\n const items = element.items.map(item => Object.assign({}, item, { nextAttrs: from }));\n attributes.from = element.transformElementItems(items, element.mark.markType, computePoints);\n }\n }\n if (attributes?.to) {\n const to = attributes.to;\n Object.keys(to).forEach(channel => {\n if (isNil(to[channel])) {\n delete to[channel];\n }\n });\n const computePoints = isValidPointsChannel(Object.keys(to), element.mark.markType) && !isValid(to.segments);\n if (computePoints) {\n const items = element.items.map(item => Object.assign({}, item, { nextAttrs: to }));\n attributes.to = element.transformElementItems(items, element.mark.markType, computePoints);\n }\n }\n\n return attributes;\n};\n\nexport function typeAnimationAttributes(\n element: IElement,\n effect: IAnimationEffect,\n animationParameters: IAnimationParameters,\n parameters: any\n): IParsedAnimationAttrs {\n // const parameters =\n const options = isFunction(effect.options)\n ? effect.options.call(null, element.getDatum(), element, parameters)\n : effect.options;\n if (!effect.type || !Factory.getAnimationType(effect.type)) {\n return null;\n }\n const attributes = Factory.getAnimationType(effect.type)(element as IGlyphElement, options, animationParameters);\n return transformAnimationAttributes(attributes, element);\n}\n\nconst parseChannelValue = (\n element: IElement,\n channel: string,\n channelValue: any,\n animationParameters: IAnimationParameters,\n parameters: any\n) => {\n return isFunction(channelValue) ? channelValue(element.getDatum(), element, parameters) : channelValue;\n};\n\nexport function channelAnimationAttributes(\n element: IElement,\n effect: IAnimationEffect,\n animationParameters: IAnimationParameters,\n parameters: any\n): IParsedAnimationAttrs {\n const channel = effect.channel;\n let attributes: IParsedAnimationAttrs = null;\n\n if (isArray(channel)) {\n attributes = channel.reduce(\n (res, key) => {\n res.from[key] = element.getGraphicAttribute(key, true);\n res.to[key] = element.getGraphicAttribute(key, false);\n return res;\n },\n { from: {}, to: {} }\n );\n } else if (isObject(channel)) {\n attributes = Object.keys(channel).reduce(\n (res, key) => {\n const hasFrom = !isNil(channel[key]?.from);\n const hasTo = !isNil(channel[key]?.to);\n\n if (hasFrom || hasTo) {\n res.from[key] = hasFrom\n ? parseChannelValue(element, key, channel[key].from, animationParameters, parameters)\n : undefined;\n res.to[key] = hasTo\n ? parseChannelValue(element, key, channel[key].to, animationParameters, parameters)\n : element.getGraphicAttribute(key, false);\n }\n\n return res;\n },\n { from: {}, to: {} }\n );\n }\n\n return transformAnimationAttributes(attributes, element);\n}\n\nexport class CustomInterpolator extends ACustomAnimate<any> {\n private _element: IElement;\n private _interpolator?: IAnimationChannelInterpolator;\n\n constructor(\n from: any,\n to: any,\n duration: number,\n easing: EasingType,\n params: { interpolator: IAnimationChannelInterpolator; element: IElement; parameters?: any }\n ) {\n super(from, to, duration, easing, params);\n this._interpolator = params?.interpolator;\n this._element = params?.element;\n }\n\n onBind() {\n this.from = this.from ?? {};\n this.to = this.to ?? {};\n }\n\n getEndProps(): void | Record<string, any> {\n return this.to;\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n if (!this._interpolator || !this._element) {\n return;\n }\n this._interpolator.call(\n this,\n ratio,\n this.from,\n this.to,\n out,\n this._element.getDatum(),\n this._element,\n this.params.parameters\n );\n }\n}\n\nexport class AttributeAnimate extends ACustomAnimate<any> {\n declare target: IGraphic;\n\n private _fromAttribute: any;\n private _toAttribute: any;\n\n getEndProps(): Record<string, any> {\n return this.to;\n }\n\n onBind() {\n this.from = this.from ?? {};\n this.to = this.to ?? {};\n }\n\n onStart(): void {\n const excludedChannelMap = (this.target.constructor as any).NOWORK_ANIMATE_ATTR ?? NOWORK_ANIMATE_ATTR;\n const excludedChannels = Object.keys(excludedChannelMap).filter(channel => excludedChannelMap[channel] !== 0);\n this.subAnimate.animate.preventAttrs(excludedChannels);\n\n const from = Object.assign({}, this.from);\n const to = Object.assign({}, this.to);\n Object.keys(to).forEach(k => {\n if (excludedChannels.includes(k)) {\n from[k] = to[k];\n this.from[k] = to[k];\n } else if (isNil(from[k])) {\n from[k] = this.target.getComputedAttribute(k);\n }\n // if (this.to[k] === from[k]) {\n // delete from[k];\n // }\n });\n\n this.target.setAttributes(from, false, {\n type: AttributeUpdateType.ANIMATE_UPDATE,\n animationState: { ratio: 0, end: false }\n });\n\n this._fromAttribute = from;\n this._toAttribute = to;\n }\n\n onEnd(): void {\n this.target.setAttributes(this._toAttribute, false, {\n type: AttributeUpdateType.ANIMATE_END\n });\n }\n\n update(end: boolean, ratio: number, out: Record<string, any>): void {\n if (this.updateCount === 0) {\n this.onFirstRun();\n }\n this.updateCount += 1;\n\n // Hack: waiting for canopus to remove invalid key when updating\n const lastProps = this.step.getLastProps();\n Object.keys(lastProps).forEach(key => {\n if (this.subAnimate.animate.validAttr(key)) {\n out[key] = lastProps[key];\n }\n });\n this.onUpdate(end, ratio, out);\n if (end) {\n this.onEnd();\n }\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n this.target.stepInterpolate(\n this.subAnimate,\n this.subAnimate.animate,\n out,\n this.step,\n ratio,\n end,\n this._toAttribute,\n this._fromAttribute\n );\n }\n}\n"]}
|
package/es/index.d.ts
CHANGED
package/es/index.js
CHANGED
package/es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,OAAO,GAAG,
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,OAAO,GAAG,eAAe,CAAC;AAEvC,cAAc,SAAS,CAAC;AAExB,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EACL,cAAc,EACd,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,EACZ,eAAe,EAChB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,6BAA6B,CAAC","file":"index.js","sourcesContent":["// -- Exports -----\nexport const version = \"0.7.4-alpha.0\";\n\nexport * from './graph';\n\nexport { View } from './view';\nexport { parseFunctionType, invokeFunctionType } from './parse/util';\nexport { GrammarBase } from './view/grammar-base';\nexport * from './util/text';\nexport * from './types';\nexport { Factory } from './core/factory';\nexport {\n SIGNAL_AUTOFIT,\n SIGNAL_HEIGHT,\n SIGNAL_PADDING,\n SIGNAL_VIEW_HEIGHT,\n SIGNAL_VIEW_WIDTH,\n SIGNAL_WIDTH,\n SIGNAL_VIEW_BOX\n} from './view/constants';\n\nexport { ThemeManager } from './theme/theme-manager';\n\nexport * from './glyph';\nexport * from './component';\nexport * from './transforms';\nexport * from './graph/animation/animation';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visactor/vgrammar-core",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.4-alpha.0",
|
|
4
4
|
"description": "VGrammar is a visual grammar library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"grammar",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"dist"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@visactor/vgrammar-coordinate": "0.7.
|
|
28
|
-
"@visactor/vgrammar-util": "0.7.
|
|
27
|
+
"@visactor/vgrammar-coordinate": "0.7.4-alpha.0",
|
|
28
|
+
"@visactor/vgrammar-util": "0.7.4-alpha.0",
|
|
29
29
|
"@visactor/vscale": "~0.16.0",
|
|
30
30
|
"@visactor/vrender": "~0.15.2",
|
|
31
31
|
"@visactor/vrender-components": "~0.15.2",
|