@visactor/vrender-animate 0.22.4
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/README.md +177 -0
- package/cjs/animate-extension.d.ts +15 -0
- package/cjs/animate-extension.js +46 -0
- package/cjs/animate-extension.js.map +1 -0
- package/cjs/animate.d.ts +71 -0
- package/cjs/animate.js +210 -0
- package/cjs/animate.js.map +1 -0
- package/cjs/custom/clip-graphic.d.ts +53 -0
- package/cjs/custom/clip-graphic.js +146 -0
- package/cjs/custom/clip-graphic.js.map +1 -0
- package/cjs/custom/clip.d.ts +13 -0
- package/cjs/custom/clip.js +24 -0
- package/cjs/custom/clip.js.map +1 -0
- package/cjs/custom/common.d.ts +22 -0
- package/cjs/custom/common.js +58 -0
- package/cjs/custom/common.js.map +1 -0
- package/cjs/custom/custom-animate.d.ts +15 -0
- package/cjs/custom/custom-animate.js +25 -0
- package/cjs/custom/custom-animate.js.map +1 -0
- package/cjs/custom/fade.d.ts +13 -0
- package/cjs/custom/fade.js +24 -0
- package/cjs/custom/fade.js.map +1 -0
- package/cjs/custom/group-fade.d.ts +16 -0
- package/cjs/custom/group-fade.js +66 -0
- package/cjs/custom/group-fade.js.map +1 -0
- package/cjs/custom/growAngle.d.ts +37 -0
- package/cjs/custom/growAngle.js +140 -0
- package/cjs/custom/growAngle.js.map +1 -0
- package/cjs/custom/growCenter.d.ts +17 -0
- package/cjs/custom/growCenter.js +161 -0
- package/cjs/custom/growCenter.js.map +1 -0
- package/cjs/custom/growHeight.d.ts +36 -0
- package/cjs/custom/growHeight.js +154 -0
- package/cjs/custom/growHeight.js.map +1 -0
- package/cjs/custom/growPoints.d.ts +52 -0
- package/cjs/custom/growPoints.js +227 -0
- package/cjs/custom/growPoints.js.map +1 -0
- package/cjs/custom/growRadius.d.ts +41 -0
- package/cjs/custom/growRadius.js +113 -0
- package/cjs/custom/growRadius.js.map +1 -0
- package/cjs/custom/growWidth.d.ts +36 -0
- package/cjs/custom/growWidth.js +154 -0
- package/cjs/custom/growWidth.js.map +1 -0
- package/cjs/custom/input-text.d.ts +29 -0
- package/cjs/custom/input-text.js +45 -0
- package/cjs/custom/input-text.js.map +1 -0
- package/cjs/custom/number.d.ts +25 -0
- package/cjs/custom/number.js +102 -0
- package/cjs/custom/number.js.map +1 -0
- package/cjs/custom/register.d.ts +1 -0
- package/cjs/custom/register.js +35 -0
- package/cjs/custom/register.js.map +1 -0
- package/cjs/custom/scale-in.d.ts +13 -0
- package/cjs/custom/scale-in.js +57 -0
- package/cjs/custom/scale-in.js.map +1 -0
- package/cjs/custom/scale.d.ts +20 -0
- package/cjs/custom/scale.js +106 -0
- package/cjs/custom/scale.js.map +1 -0
- package/cjs/custom/sphere.d.ts +20 -0
- package/cjs/custom/sphere.js +26 -0
- package/cjs/custom/sphere.js.map +1 -0
- package/cjs/custom/state.d.ts +13 -0
- package/cjs/custom/state.js +25 -0
- package/cjs/custom/state.js.map +1 -0
- package/cjs/custom/tag-points.d.ts +26 -0
- package/cjs/custom/tag-points.js +81 -0
- package/cjs/custom/tag-points.js.map +1 -0
- package/cjs/custom/update.d.ts +14 -0
- package/cjs/custom/update.js +26 -0
- package/cjs/custom/update.js.map +1 -0
- package/cjs/executor/animate-executor.d.ts +36 -0
- package/cjs/executor/animate-executor.js +177 -0
- package/cjs/executor/animate-executor.js.map +1 -0
- package/cjs/executor/executor.d.ts +69 -0
- package/cjs/executor/executor.js +6 -0
- package/cjs/executor/executor.js.map +1 -0
- package/cjs/index.d.ts +25 -0
- package/cjs/index.js +214 -0
- package/cjs/index.js.map +1 -0
- package/cjs/interpolate/executor.d.ts +66 -0
- package/cjs/interpolate/executor.js +6 -0
- package/cjs/interpolate/executor.js.map +1 -0
- package/cjs/interpolate/number.d.ts +1 -0
- package/cjs/interpolate/number.js +10 -0
- package/cjs/interpolate/number.js.map +1 -0
- package/cjs/interpolate/store.d.ts +32 -0
- package/cjs/interpolate/store.js +96 -0
- package/cjs/interpolate/store.js.map +1 -0
- package/cjs/intreface/animate.d.ts +91 -0
- package/cjs/intreface/animate.js +10 -0
- package/cjs/intreface/animate.js.map +1 -0
- package/cjs/intreface/easing.d.ts +3 -0
- package/cjs/intreface/easing.js +6 -0
- package/cjs/intreface/easing.js.map +1 -0
- package/cjs/intreface/state.d.ts +35 -0
- package/cjs/intreface/state.js +6 -0
- package/cjs/intreface/state.js.map +1 -0
- package/cjs/intreface/ticker.d.ts +37 -0
- package/cjs/intreface/ticker.js +10 -0
- package/cjs/intreface/ticker.js.map +1 -0
- package/cjs/intreface/timeline.d.ts +17 -0
- package/cjs/intreface/timeline.js +6 -0
- package/cjs/intreface/timeline.js.map +1 -0
- package/cjs/intreface/type.d.ts +13 -0
- package/cjs/intreface/type.js +15 -0
- package/cjs/intreface/type.js.map +1 -0
- package/cjs/register.d.ts +1 -0
- package/cjs/register.js +19 -0
- package/cjs/register.js.map +1 -0
- package/cjs/state/animation-state-machine.d.ts +22 -0
- package/cjs/state/animation-state-machine.js +53 -0
- package/cjs/state/animation-state-machine.js.map +1 -0
- package/cjs/state/animation-state-queue.d.ts +24 -0
- package/cjs/state/animation-state-queue.js +66 -0
- package/cjs/state/animation-state-queue.js.map +1 -0
- package/cjs/state/animation-state-registry.d.ts +14 -0
- package/cjs/state/animation-state-registry.js +53 -0
- package/cjs/state/animation-state-registry.js.map +1 -0
- package/cjs/state/animation-state.d.ts +25 -0
- package/cjs/state/animation-state.js +80 -0
- package/cjs/state/animation-state.js.map +1 -0
- package/cjs/state/animation-states-registry.d.ts +17 -0
- package/cjs/state/animation-states-registry.js +95 -0
- package/cjs/state/animation-states-registry.js.map +1 -0
- package/cjs/state/graphic-extension.d.ts +12 -0
- package/cjs/state/graphic-extension.js +37 -0
- package/cjs/state/graphic-extension.js.map +1 -0
- package/cjs/state/index.d.ts +3 -0
- package/cjs/state/index.js +22 -0
- package/cjs/state/index.js.map +1 -0
- package/cjs/state/types.d.ts +11 -0
- package/cjs/state/types.js +6 -0
- package/cjs/state/types.js.map +1 -0
- package/cjs/step.d.ts +49 -0
- package/cjs/step.js +124 -0
- package/cjs/step.js.map +1 -0
- package/cjs/ticker/default-ticker.d.ts +39 -0
- package/cjs/ticker/default-ticker.js +133 -0
- package/cjs/ticker/default-ticker.js.map +1 -0
- package/cjs/ticker/manual-ticker.d.ts +6 -0
- package/cjs/ticker/manual-ticker.js +37 -0
- package/cjs/ticker/manual-ticker.js.map +1 -0
- package/cjs/timeline.d.ts +34 -0
- package/cjs/timeline.js +84 -0
- package/cjs/timeline.js.map +1 -0
- package/cjs/utils/easing-func.d.ts +1 -0
- package/cjs/utils/easing-func.js +16 -0
- package/cjs/utils/easing-func.js.map +1 -0
- package/cjs/utils/easing.d.ts +49 -0
- package/cjs/utils/easing.js +141 -0
- package/cjs/utils/easing.js.map +1 -0
- package/dist/index.es.js +3824 -0
- package/es/animate-extension.d.ts +15 -0
- package/es/animate-extension.js +42 -0
- package/es/animate-extension.js.map +1 -0
- package/es/animate.d.ts +71 -0
- package/es/animate.js +207 -0
- package/es/animate.js.map +1 -0
- package/es/custom/clip-graphic.d.ts +53 -0
- package/es/custom/clip-graphic.js +134 -0
- package/es/custom/clip-graphic.js.map +1 -0
- package/es/custom/clip.d.ts +13 -0
- package/es/custom/clip.js +14 -0
- package/es/custom/clip.js.map +1 -0
- package/es/custom/common.d.ts +22 -0
- package/es/custom/common.js +48 -0
- package/es/custom/common.js.map +1 -0
- package/es/custom/custom-animate.d.ts +15 -0
- package/es/custom/custom-animate.js +17 -0
- package/es/custom/custom-animate.js.map +1 -0
- package/es/custom/fade.d.ts +13 -0
- package/es/custom/fade.js +14 -0
- package/es/custom/fade.js.map +1 -0
- package/es/custom/group-fade.d.ts +16 -0
- package/es/custom/group-fade.js +56 -0
- package/es/custom/group-fade.js.map +1 -0
- package/es/custom/growAngle.d.ts +37 -0
- package/es/custom/growAngle.js +132 -0
- package/es/custom/growAngle.js.map +1 -0
- package/es/custom/growCenter.d.ts +17 -0
- package/es/custom/growCenter.js +155 -0
- package/es/custom/growCenter.js.map +1 -0
- package/es/custom/growHeight.d.ts +36 -0
- package/es/custom/growHeight.js +144 -0
- package/es/custom/growHeight.js.map +1 -0
- package/es/custom/growPoints.d.ts +52 -0
- package/es/custom/growPoints.js +219 -0
- package/es/custom/growPoints.js.map +1 -0
- package/es/custom/growRadius.d.ts +41 -0
- package/es/custom/growRadius.js +105 -0
- package/es/custom/growRadius.js.map +1 -0
- package/es/custom/growWidth.d.ts +36 -0
- package/es/custom/growWidth.js +144 -0
- package/es/custom/growWidth.js.map +1 -0
- package/es/custom/input-text.d.ts +29 -0
- package/es/custom/input-text.js +37 -0
- package/es/custom/input-text.js.map +1 -0
- package/es/custom/number.d.ts +25 -0
- package/es/custom/number.js +94 -0
- package/es/custom/number.js.map +1 -0
- package/es/custom/register.d.ts +1 -0
- package/es/custom/register.js +39 -0
- package/es/custom/register.js.map +1 -0
- package/es/custom/scale-in.d.ts +13 -0
- package/es/custom/scale-in.js +49 -0
- package/es/custom/scale-in.js.map +1 -0
- package/es/custom/scale.d.ts +20 -0
- package/es/custom/scale.js +96 -0
- package/es/custom/scale.js.map +1 -0
- package/es/custom/sphere.d.ts +20 -0
- package/es/custom/sphere.js +20 -0
- package/es/custom/sphere.js.map +1 -0
- package/es/custom/state.d.ts +13 -0
- package/es/custom/state.js +17 -0
- package/es/custom/state.js.map +1 -0
- package/es/custom/tag-points.d.ts +26 -0
- package/es/custom/tag-points.js +77 -0
- package/es/custom/tag-points.js.map +1 -0
- package/es/custom/update.d.ts +14 -0
- package/es/custom/update.js +18 -0
- package/es/custom/update.js.map +1 -0
- package/es/executor/animate-executor.d.ts +36 -0
- package/es/executor/animate-executor.js +169 -0
- package/es/executor/animate-executor.js.map +1 -0
- package/es/executor/executor.d.ts +69 -0
- package/es/executor/executor.js +2 -0
- package/es/executor/executor.js.map +1 -0
- package/es/index.d.ts +25 -0
- package/es/index.js +50 -0
- package/es/index.js.map +1 -0
- package/es/interpolate/executor.d.ts +66 -0
- package/es/interpolate/executor.js +2 -0
- package/es/interpolate/executor.js.map +1 -0
- package/es/interpolate/number.d.ts +1 -0
- package/es/interpolate/number.js +4 -0
- package/es/interpolate/number.js.map +1 -0
- package/es/interpolate/store.d.ts +32 -0
- package/es/interpolate/store.js +88 -0
- package/es/interpolate/store.js.map +1 -0
- package/es/intreface/animate.d.ts +91 -0
- package/es/intreface/animate.js +6 -0
- package/es/intreface/animate.js.map +1 -0
- package/es/intreface/easing.d.ts +3 -0
- package/es/intreface/easing.js +2 -0
- package/es/intreface/easing.js.map +1 -0
- package/es/intreface/state.d.ts +35 -0
- package/es/intreface/state.js +2 -0
- package/es/intreface/state.js.map +1 -0
- package/es/intreface/ticker.d.ts +37 -0
- package/es/intreface/ticker.js +6 -0
- package/es/intreface/ticker.js.map +1 -0
- package/es/intreface/timeline.d.ts +17 -0
- package/es/intreface/timeline.js +2 -0
- package/es/intreface/timeline.js.map +1 -0
- package/es/intreface/type.d.ts +13 -0
- package/es/intreface/type.js +14 -0
- package/es/intreface/type.js.map +1 -0
- package/es/register.d.ts +1 -0
- package/es/register.js +20 -0
- package/es/register.js.map +1 -0
- package/es/state/animation-state-machine.d.ts +22 -0
- package/es/state/animation-state-machine.js +47 -0
- package/es/state/animation-state-machine.js.map +1 -0
- package/es/state/animation-state-queue.d.ts +24 -0
- package/es/state/animation-state-queue.js +58 -0
- package/es/state/animation-state-queue.js.map +1 -0
- package/es/state/animation-state-registry.d.ts +14 -0
- package/es/state/animation-state-registry.js +45 -0
- package/es/state/animation-state-registry.js.map +1 -0
- package/es/state/animation-state.d.ts +25 -0
- package/es/state/animation-state.js +72 -0
- package/es/state/animation-state.js.map +1 -0
- package/es/state/animation-states-registry.d.ts +17 -0
- package/es/state/animation-states-registry.js +87 -0
- package/es/state/animation-states-registry.js.map +1 -0
- package/es/state/graphic-extension.d.ts +12 -0
- package/es/state/graphic-extension.js +29 -0
- package/es/state/graphic-extension.js.map +1 -0
- package/es/state/index.d.ts +3 -0
- package/es/state/index.js +6 -0
- package/es/state/index.js.map +1 -0
- package/es/state/types.d.ts +11 -0
- package/es/state/types.js +2 -0
- package/es/state/types.js.map +1 -0
- package/es/step.d.ts +49 -0
- package/es/step.js +120 -0
- package/es/step.js.map +1 -0
- package/es/ticker/default-ticker.d.ts +39 -0
- package/es/ticker/default-ticker.js +129 -0
- package/es/ticker/default-ticker.js.map +1 -0
- package/es/ticker/manual-ticker.d.ts +6 -0
- package/es/ticker/manual-ticker.js +29 -0
- package/es/ticker/manual-ticker.js.map +1 -0
- package/es/timeline.d.ts +34 -0
- package/es/timeline.js +79 -0
- package/es/timeline.js.map +1 -0
- package/es/utils/easing-func.d.ts +1 -0
- package/es/utils/easing-func.js +8 -0
- package/es/utils/easing-func.js.map +1 -0
- package/es/utils/easing.d.ts +49 -0
- package/es/utils/easing.js +134 -0
- package/es/utils/easing.js.map +1 -0
- package/package.json +72 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/custom/register.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EACL,YAAY,EACZ,aAAa,EACb,aAAa,EACb,cAAc,EACd,aAAa,EACb,cAAc,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,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AE,aAAa,CAAC,CAAC;IACvE,eAAe,CAAC,sBAAsB,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAC;IACzE,eAAe,CAAC,sBAAsB,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;IACnE,eAAe,CAAC,sBAAsB,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;IACrE,eAAe,CAAC,sBAAsB,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;IACrE,eAAe,CAAC,sBAAsB,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;IAEvE,eAAe,CAAC,sBAAsB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACzD,eAAe,CAAC,sBAAsB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AACzD,CAAC,CAAC","file":"register.js","sourcesContent":["import { AnimateExecutor } from '../executor/animate-executor';\nimport { ClipIn, ClipOut } from './clip';\nimport { FadeIn, FadeOut } from './fade';\nimport { GrowAngleIn, GrowAngleOut } from './growAngle';\nimport { GrowCenterIn, GrowCenterOut } from './growCenter';\nimport { GrowHeightIn, GrowHeightOut } from './growHeight';\nimport {\n GrowPointsIn,\n GrowPointsOut,\n GrowPointsXIn,\n GrowPointsXOut,\n GrowPointsYIn,\n GrowPointsYOut\n} from './growPoints';\nimport { GrowRadiusIn, GrowRadiusOut } from './growRadius';\nimport { GrowWidthIn, GrowWidthOut } from './growWidth';\nimport { ScaleIn, ScaleOut } from './scale';\nimport { State } from './state';\nimport { Update } from './update';\n\nexport const registerCustomAnimate = () => {\n AnimateExecutor.registerBuiltInAnimate('scaleIn', ScaleIn);\n AnimateExecutor.registerBuiltInAnimate('scaleOut', ScaleOut);\n AnimateExecutor.registerBuiltInAnimate('growHeightIn', GrowHeightIn);\n AnimateExecutor.registerBuiltInAnimate('growHeightOut', GrowHeightOut);\n AnimateExecutor.registerBuiltInAnimate('growWidthIn', GrowWidthIn);\n AnimateExecutor.registerBuiltInAnimate('growWidthOut', GrowWidthOut);\n AnimateExecutor.registerBuiltInAnimate('growCenterIn', GrowCenterIn);\n AnimateExecutor.registerBuiltInAnimate('growCenterOut', GrowCenterOut);\n AnimateExecutor.registerBuiltInAnimate('clipIn', ClipIn);\n AnimateExecutor.registerBuiltInAnimate('clipOut', ClipOut);\n AnimateExecutor.registerBuiltInAnimate('fadeIn', FadeIn);\n AnimateExecutor.registerBuiltInAnimate('fadeOut', FadeOut);\n AnimateExecutor.registerBuiltInAnimate('growPointsIn', GrowPointsIn);\n AnimateExecutor.registerBuiltInAnimate('growPointsOut', GrowPointsOut);\n AnimateExecutor.registerBuiltInAnimate('growPointsXIn', GrowPointsXIn);\n AnimateExecutor.registerBuiltInAnimate('growPointsXOut', GrowPointsXOut);\n AnimateExecutor.registerBuiltInAnimate('growPointsYIn', GrowPointsYIn);\n AnimateExecutor.registerBuiltInAnimate('growPointsYOut', GrowPointsYOut);\n AnimateExecutor.registerBuiltInAnimate('growAngleIn', GrowAngleIn);\n AnimateExecutor.registerBuiltInAnimate('growAngleOut', GrowAngleOut);\n AnimateExecutor.registerBuiltInAnimate('growRadiusIn', GrowRadiusIn);\n AnimateExecutor.registerBuiltInAnimate('growRadiusOut', GrowRadiusOut);\n // state和update共用一个自定义动画类\n AnimateExecutor.registerBuiltInAnimate('update', Update);\n AnimateExecutor.registerBuiltInAnimate('state', State);\n};\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IAnimate, IStep } from '../intreface/animate';
|
|
2
|
+
import type { EasingType } from '../intreface/easing';
|
|
3
|
+
import { ACustomAnimate } from './custom-animate';
|
|
4
|
+
export interface IScaleAnimationOptions {
|
|
5
|
+
direction?: 'x' | 'y' | 'xy';
|
|
6
|
+
}
|
|
7
|
+
export declare class ScaleIn extends ACustomAnimate<Record<string, number>> {
|
|
8
|
+
valid: boolean;
|
|
9
|
+
constructor(from: null, to: null, duration: number, easing: EasingType, params?: IScaleAnimationOptions);
|
|
10
|
+
onFirstRun(): void;
|
|
11
|
+
onEnd(cb?: (animate: IAnimate, step: IStep) => void): void;
|
|
12
|
+
onUpdate(end: boolean, ratio: number, out: Record<string, any>): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ACustomAnimate } from "./custom-animate";
|
|
2
|
+
|
|
3
|
+
export class ScaleIn extends ACustomAnimate {
|
|
4
|
+
constructor(from, to, duration, easing, params) {
|
|
5
|
+
super(from, to, duration, easing, params);
|
|
6
|
+
}
|
|
7
|
+
onFirstRun() {
|
|
8
|
+
var _a, _b, _c, _d, _e;
|
|
9
|
+
let from, to;
|
|
10
|
+
const attrs = this.target.getAttributes();
|
|
11
|
+
switch (null === (_a = this.params) || void 0 === _a ? void 0 : _a.direction) {
|
|
12
|
+
case "x":
|
|
13
|
+
from = {
|
|
14
|
+
scaleX: 0
|
|
15
|
+
}, to = {
|
|
16
|
+
scaleX: null !== (_b = null == attrs ? void 0 : attrs.scaleX) && void 0 !== _b ? _b : 1
|
|
17
|
+
};
|
|
18
|
+
break;
|
|
19
|
+
|
|
20
|
+
case "y":
|
|
21
|
+
from = {
|
|
22
|
+
scaleY: 0
|
|
23
|
+
}, to = {
|
|
24
|
+
scaleY: null !== (_c = null == attrs ? void 0 : attrs.scaleY) && void 0 !== _c ? _c : 1
|
|
25
|
+
};
|
|
26
|
+
break;
|
|
27
|
+
|
|
28
|
+
default:
|
|
29
|
+
from = {
|
|
30
|
+
scaleX: 0,
|
|
31
|
+
scaleY: 0
|
|
32
|
+
}, to = {
|
|
33
|
+
scaleX: null !== (_d = null == attrs ? void 0 : attrs.scaleX) && void 0 !== _d ? _d : 1,
|
|
34
|
+
scaleY: null !== (_e = null == attrs ? void 0 : attrs.scaleY) && void 0 !== _e ? _e : 1
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
this.props = to, this.propKeys = Object.keys(to), this.animate.reSyncProps(), this.from = from,
|
|
38
|
+
this.to = to;
|
|
39
|
+
}
|
|
40
|
+
onEnd(cb) {
|
|
41
|
+
super.onEnd(cb);
|
|
42
|
+
}
|
|
43
|
+
onUpdate(end, ratio, out) {
|
|
44
|
+
this.valid && (this.propKeys.forEach((key => {
|
|
45
|
+
out[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;
|
|
46
|
+
})), this.target.setAttributes(out));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=scale-in.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/custom/scale-in.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAWlD,MAAM,OAAO,OAAQ,SAAQ,cAAsC;IAGjE,YAAY,IAAU,EAAE,EAAQ,EAAE,QAAgB,EAAE,MAAkB,EAAE,MAA+B;QACrG,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5C,CAAC;IAED,UAAU;;QACR,IAAI,IAA4B,CAAC;QACjC,IAAI,EAA0B,CAAC;QAE/B,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;QAC1C,QAAQ,MAAA,IAAI,CAAC,MAAM,0CAAE,SAAS,EAAE;YAC9B,KAAK,GAAG;gBACN,IAAI,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;gBACrB,EAAE,GAAG,EAAE,MAAM,EAAE,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,mCAAI,CAAC,EAAE,CAAC;gBACpC,MAAM;YACR,KAAK,GAAG;gBACN,IAAI,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;gBACrB,EAAE,GAAG,EAAE,MAAM,EAAE,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,mCAAI,CAAC,EAAE,CAAC;gBACpC,MAAM;YACR,KAAK,IAAI,CAAC;YACV;gBACE,IAAI,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;gBAChC,EAAE,GAAG;oBACH,MAAM,EAAE,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,mCAAI,CAAC;oBAC1B,MAAM,EAAE,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,mCAAI,CAAC;iBAC3B,CAAC;SACL;QACD,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAChC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,CAAC;IAED,KAAK,CAAC,EAA6C;QACjD,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAClB,CAAC;IAED,QAAQ,CAAC,GAAY,EAAE,KAAa,EAAE,GAAwB;QAC5D,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;YACf,OAAO;SACR;QAED,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YAC1B,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;QACtE,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC;CACF","file":"scale-in.js","sourcesContent":["import type { IAnimate, IStep } from '../intreface/animate';\nimport type { EasingType } from '../intreface/easing';\nimport { ACustomAnimate } from './custom-animate';\n\nexport interface IScaleAnimationOptions {\n direction?: 'x' | 'y' | 'xy';\n}\n\n/**\n * 文本输入动画,实现类似打字机的字符逐个显示效果\n * 支持通过beforeText和afterText参数添加前缀和后缀\n * 支持通过showCursor参数显示光标,cursorChar自定义光标字符\n */\nexport class ScaleIn extends ACustomAnimate<Record<string, number>> {\n declare valid: boolean;\n\n constructor(from: null, to: null, duration: number, easing: EasingType, params?: IScaleAnimationOptions) {\n super(from, to, duration, easing, params);\n }\n\n onFirstRun(): void {\n let from: Record<string, number>;\n let to: Record<string, number>;\n // 获取当前的数据\n const attrs = this.target.getAttributes();\n switch (this.params?.direction) {\n case 'x':\n from = { scaleX: 0 };\n to = { scaleX: attrs?.scaleX ?? 1 };\n break;\n case 'y':\n from = { scaleY: 0 };\n to = { scaleY: attrs?.scaleY ?? 1 };\n break;\n case 'xy':\n default:\n from = { scaleX: 0, scaleY: 0 };\n to = {\n scaleX: attrs?.scaleX ?? 1,\n scaleY: attrs?.scaleY ?? 1\n };\n }\n this.props = to;\n this.propKeys = Object.keys(to);\n this.animate.reSyncProps();\n this.from = from;\n this.to = to;\n }\n\n onEnd(cb?: (animate: IAnimate, step: IStep) => void): void {\n super.onEnd(cb);\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n if (!this.valid) {\n return;\n }\n\n this.propKeys.forEach(key => {\n out[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;\n });\n this.target.setAttributes(out);\n }\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { IAnimate, IStep } from '../intreface/animate';
|
|
2
|
+
import type { EasingType } from '../intreface/easing';
|
|
3
|
+
import { ACustomAnimate } from './custom-animate';
|
|
4
|
+
export interface IScaleAnimationOptions {
|
|
5
|
+
direction?: 'x' | 'y' | 'xy';
|
|
6
|
+
}
|
|
7
|
+
export declare class ScaleIn extends ACustomAnimate<Record<string, number>> {
|
|
8
|
+
valid: boolean;
|
|
9
|
+
constructor(from: null, to: null, duration: number, easing: EasingType, params?: IScaleAnimationOptions);
|
|
10
|
+
onBind(): void;
|
|
11
|
+
onEnd(cb?: (animate: IAnimate, step: IStep) => void): void;
|
|
12
|
+
onUpdate(end: boolean, ratio: number, out: Record<string, any>): void;
|
|
13
|
+
}
|
|
14
|
+
export declare class ScaleOut extends ACustomAnimate<Record<string, number>> {
|
|
15
|
+
valid: boolean;
|
|
16
|
+
constructor(from: null, to: null, duration: number, easing: EasingType, params?: IScaleAnimationOptions);
|
|
17
|
+
onBind(): void;
|
|
18
|
+
onEnd(cb?: (animate: IAnimate, step: IStep) => void): void;
|
|
19
|
+
onUpdate(end: boolean, ratio: number, out: Record<string, any>): void;
|
|
20
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { ACustomAnimate } from "./custom-animate";
|
|
2
|
+
|
|
3
|
+
export class ScaleIn extends ACustomAnimate {
|
|
4
|
+
constructor(from, to, duration, easing, params) {
|
|
5
|
+
super(from, to, duration, easing, params);
|
|
6
|
+
}
|
|
7
|
+
onBind() {
|
|
8
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
9
|
+
let from, to;
|
|
10
|
+
const attrs = this.target.getFinalAttribute(), fromAttrs = null !== (_a = this.target.context.lastAttrs) && void 0 !== _a ? _a : {};
|
|
11
|
+
switch (null === (_b = this.params) || void 0 === _b ? void 0 : _b.direction) {
|
|
12
|
+
case "x":
|
|
13
|
+
from = {
|
|
14
|
+
scaleX: null !== (_c = fromAttrs.scaleX) && void 0 !== _c ? _c : 0
|
|
15
|
+
}, to = {
|
|
16
|
+
scaleX: null !== (_d = null == attrs ? void 0 : attrs.scaleX) && void 0 !== _d ? _d : 1
|
|
17
|
+
};
|
|
18
|
+
break;
|
|
19
|
+
|
|
20
|
+
case "y":
|
|
21
|
+
from = {
|
|
22
|
+
scaleY: null !== (_e = fromAttrs.scaleY) && void 0 !== _e ? _e : 0
|
|
23
|
+
}, to = {
|
|
24
|
+
scaleY: null !== (_f = null == attrs ? void 0 : attrs.scaleY) && void 0 !== _f ? _f : 1
|
|
25
|
+
};
|
|
26
|
+
break;
|
|
27
|
+
|
|
28
|
+
default:
|
|
29
|
+
from = {
|
|
30
|
+
scaleX: null !== (_g = fromAttrs.scaleX) && void 0 !== _g ? _g : 0,
|
|
31
|
+
scaleY: null !== (_h = fromAttrs.scaleY) && void 0 !== _h ? _h : 0
|
|
32
|
+
}, to = {
|
|
33
|
+
scaleX: null !== (_j = null == attrs ? void 0 : attrs.scaleX) && void 0 !== _j ? _j : 1,
|
|
34
|
+
scaleY: null !== (_k = null == attrs ? void 0 : attrs.scaleY) && void 0 !== _k ? _k : 1
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
this.props = to, this.propKeys = Object.keys(to), this.animate.reSyncProps(), this.from = from,
|
|
38
|
+
this.to = to, this.target.setAttributes(from);
|
|
39
|
+
}
|
|
40
|
+
onEnd(cb) {
|
|
41
|
+
super.onEnd(cb);
|
|
42
|
+
}
|
|
43
|
+
onUpdate(end, ratio, out) {
|
|
44
|
+
this.propKeys.forEach((key => {
|
|
45
|
+
out[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;
|
|
46
|
+
})), this.target.setAttributes(out);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export class ScaleOut extends ACustomAnimate {
|
|
51
|
+
constructor(from, to, duration, easing, params) {
|
|
52
|
+
super(from, to, duration, easing, params);
|
|
53
|
+
}
|
|
54
|
+
onBind() {
|
|
55
|
+
var _a, _b, _c, _d, _e;
|
|
56
|
+
let from, to;
|
|
57
|
+
const attrs = this.target.getFinalAttribute();
|
|
58
|
+
switch (null === (_a = this.params) || void 0 === _a ? void 0 : _a.direction) {
|
|
59
|
+
case "x":
|
|
60
|
+
from = {
|
|
61
|
+
scaleX: null !== (_b = null == attrs ? void 0 : attrs.scaleX) && void 0 !== _b ? _b : 1
|
|
62
|
+
}, to = {
|
|
63
|
+
scaleX: 0
|
|
64
|
+
};
|
|
65
|
+
break;
|
|
66
|
+
|
|
67
|
+
case "y":
|
|
68
|
+
from = {
|
|
69
|
+
scaleY: null !== (_c = null == attrs ? void 0 : attrs.scaleY) && void 0 !== _c ? _c : 1
|
|
70
|
+
}, to = {
|
|
71
|
+
scaleY: 0
|
|
72
|
+
};
|
|
73
|
+
break;
|
|
74
|
+
|
|
75
|
+
default:
|
|
76
|
+
from = {
|
|
77
|
+
scaleX: null !== (_d = null == attrs ? void 0 : attrs.scaleX) && void 0 !== _d ? _d : 1,
|
|
78
|
+
scaleY: null !== (_e = null == attrs ? void 0 : attrs.scaleY) && void 0 !== _e ? _e : 1
|
|
79
|
+
}, to = {
|
|
80
|
+
scaleX: 0,
|
|
81
|
+
scaleY: 0
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
this.props = to, this.propKeys = Object.keys(to), this.animate.reSyncProps(), this.from = from,
|
|
85
|
+
this.to = to;
|
|
86
|
+
}
|
|
87
|
+
onEnd(cb) {
|
|
88
|
+
super.onEnd(cb);
|
|
89
|
+
}
|
|
90
|
+
onUpdate(end, ratio, out) {
|
|
91
|
+
this.propKeys.forEach((key => {
|
|
92
|
+
out[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;
|
|
93
|
+
})), this.target.setAttributes(out);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=scale.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/custom/scale.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAMlD,MAAM,OAAO,OAAQ,SAAQ,cAAsC;IAGjE,YAAY,IAAU,EAAE,EAAQ,EAAE,QAAgB,EAAE,MAAkB,EAAE,MAA+B;QACrG,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5C,CAAC;IAED,MAAM;;QACJ,IAAI,IAA4B,CAAC;QACjC,IAAI,EAA0B,CAAC;QAC/B,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC;QAC9C,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E,MAAM,mCAAI,CAAC,EAAE,CAAC;gBACtC,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;gBACnB,MAAM;YACR,KAAK,IAAI,CAAC;YACV;gBACE,IAAI,GAAG,EAAE,MAAM,EAAE,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,mCAAI,CAAC,EAAE,MAAM,EAAE,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,mCAAI,CAAC,EAAE,CAAC;gBAClE,EAAE,GAAG;oBACH,MAAM,EAAE,CAAC;oBACT,MAAM,EAAE,CAAC;iBACV,CAAC;SACL;QACD,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAChC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,CAAC;IAED,KAAK,CAAC,EAA6C;QACjD,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAClB,CAAC;IAED,QAAQ,CAAC,GAAY,EAAE,KAAa,EAAE,GAAwB;QAC5D,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YAC1B,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;QACtE,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC;CACF","file":"scale.js","sourcesContent":["import type { IAnimate, IStep } from '../intreface/animate';\nimport type { EasingType } from '../intreface/easing';\nimport { ACustomAnimate } from './custom-animate';\n\nexport interface IScaleAnimationOptions {\n direction?: 'x' | 'y' | 'xy';\n}\n\nexport class ScaleIn extends ACustomAnimate<Record<string, number>> {\n declare valid: boolean;\n\n constructor(from: null, to: null, duration: number, easing: EasingType, params?: IScaleAnimationOptions) {\n super(from, to, duration, easing, params);\n }\n\n onBind(): void {\n let from: Record<string, number>;\n let to: Record<string, number>;\n const attrs = this.target.getFinalAttribute();\n const fromAttrs = this.target.context.lastAttrs ?? {};\n\n switch (this.params?.direction) {\n case 'x':\n from = { scaleX: fromAttrs.scaleX ?? 0 };\n to = { scaleX: attrs?.scaleX ?? 1 };\n break;\n case 'y':\n from = { scaleY: fromAttrs.scaleY ?? 0 };\n to = { scaleY: attrs?.scaleY ?? 1 };\n break;\n case 'xy':\n default:\n from = { scaleX: fromAttrs.scaleX ?? 0, scaleY: fromAttrs.scaleY ?? 0 };\n to = {\n scaleX: attrs?.scaleX ?? 1,\n scaleY: attrs?.scaleY ?? 1\n };\n }\n this.props = to;\n this.propKeys = Object.keys(to);\n this.animate.reSyncProps();\n this.from = from;\n this.to = to;\n this.target.setAttributes(from);\n }\n\n onEnd(cb?: (animate: IAnimate, step: IStep) => void): void {\n super.onEnd(cb);\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n this.propKeys.forEach(key => {\n out[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;\n });\n this.target.setAttributes(out);\n }\n}\n\nexport class ScaleOut extends ACustomAnimate<Record<string, number>> {\n declare valid: boolean;\n\n constructor(from: null, to: null, duration: number, easing: EasingType, params?: IScaleAnimationOptions) {\n super(from, to, duration, easing, params);\n }\n\n onBind(): void {\n let from: Record<string, number>;\n let to: Record<string, number>;\n // 获取当前的数据\n const attrs = this.target.getFinalAttribute();\n switch (this.params?.direction) {\n case 'x':\n from = { scaleX: attrs?.scaleX ?? 1 };\n to = { scaleX: 0 };\n break;\n case 'y':\n from = { scaleY: attrs?.scaleY ?? 1 };\n to = { scaleY: 0 };\n break;\n case 'xy':\n default:\n from = { scaleX: attrs?.scaleX ?? 1, scaleY: attrs?.scaleY ?? 1 };\n to = {\n scaleX: 0,\n scaleY: 0\n };\n }\n this.props = to;\n this.propKeys = Object.keys(to);\n this.animate.reSyncProps();\n this.from = from;\n this.to = to;\n }\n\n onEnd(cb?: (animate: IAnimate, step: IStep) => void): void {\n super.onEnd(cb);\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n this.propKeys.forEach(key => {\n out[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;\n });\n this.target.setAttributes(out);\n }\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ACustomAnimate } from './custom-animate';
|
|
2
|
+
type RotateSphereParams = {
|
|
3
|
+
center: {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
z: number;
|
|
7
|
+
};
|
|
8
|
+
r: number;
|
|
9
|
+
cb?: (out: any) => void;
|
|
10
|
+
} | (() => any);
|
|
11
|
+
export declare class RotateBySphereAnimate extends ACustomAnimate<any> {
|
|
12
|
+
params: RotateSphereParams;
|
|
13
|
+
theta: number;
|
|
14
|
+
phi: number;
|
|
15
|
+
onStart(): void;
|
|
16
|
+
onBind(): void;
|
|
17
|
+
onEnd(): void;
|
|
18
|
+
onUpdate(end: boolean, ratio: number, out: Record<string, any>): void;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { pi, pi2 } from "@visactor/vutils";
|
|
2
|
+
|
|
3
|
+
import { ACustomAnimate } from "./custom-animate";
|
|
4
|
+
|
|
5
|
+
export class RotateBySphereAnimate extends ACustomAnimate {
|
|
6
|
+
onStart() {
|
|
7
|
+
const {center: center, r: r} = "function" == typeof this.params ? this.params() : this.params, startX = this.target.getComputedAttribute("x"), startY = this.target.getComputedAttribute("y"), startZ = this.target.getComputedAttribute("z"), phi = Math.acos((startY - center.y) / r);
|
|
8
|
+
let theta = Math.acos((startX - center.x) / r / Math.sin(phi));
|
|
9
|
+
startZ - center.z < 0 && (theta = pi2 - theta), this.theta = theta, this.phi = phi;
|
|
10
|
+
}
|
|
11
|
+
onBind() {}
|
|
12
|
+
onEnd() {}
|
|
13
|
+
onUpdate(end, ratio, out) {
|
|
14
|
+
if (null == this.phi || null == this.theta) return;
|
|
15
|
+
const {center: center, r: r, cb: cb} = "function" == typeof this.params ? this.params() : this.params, deltaAngle = 2 * Math.PI * ratio, theta = this.theta + deltaAngle, phi = this.phi, x = r * Math.sin(phi) * Math.cos(theta) + center.x, y = r * Math.cos(phi) + center.y, z = r * Math.sin(phi) * Math.sin(theta) + center.z;
|
|
16
|
+
for (out.x = x, out.y = y, out.z = z, out.alpha = theta + pi / 2; out.alpha > pi2; ) out.alpha -= pi2;
|
|
17
|
+
out.alpha = pi2 - out.alpha, out.zIndex = -1e4 * out.z, cb && cb(out);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=sphere.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/custom/sphere.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAUlD,MAAM,OAAO,qBAAsB,SAAQ,cAAmB;IAK5D,OAAO;QACL,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,IAAI,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;QACtF,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC;QACrD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC;QACrD,MAAM,MAAM,GAAG,IAAI,C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CAAC,CAAC,CAAC;QACzD,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;QACvC,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;QACzD,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;QACV,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;QACV,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;QAEV,GAAG,CAAC,KAAK,GAAG,KAAK,GAAG,EAAE,GAAG,CAAC,CAAC;QAC3B,OAAO,GAAG,CAAC,KAAK,GAAG,GAAG,EAAE;YACtB,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC;SAClB;QACD,GAAG,CAAC,KAAK,GAAG,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC;QAE5B,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC;QAE5B,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC;IAChB,CAAC;CACF","file":"sphere.js","sourcesContent":["import { pi, pi2 } from '@visactor/vutils';\nimport { ACustomAnimate } from './custom-animate';\n\ntype RotateSphereParams =\n | {\n center: { x: number; y: number; z: number };\n r: number;\n cb?: (out: any) => void;\n }\n | (() => any);\n\nexport class RotateBySphereAnimate extends ACustomAnimate<any> {\n declare params: RotateSphereParams;\n declare theta: number;\n declare phi: number;\n\n onStart(): void {\n const { center, r } = typeof this.params === 'function' ? this.params() : this.params;\n const startX = this.target.getComputedAttribute('x');\n const startY = this.target.getComputedAttribute('y');\n const startZ = this.target.getComputedAttribute('z');\n const phi = Math.acos((startY - center.y) / r);\n let theta = Math.acos((startX - center.x) / r / Math.sin(phi));\n if (startZ - center.z < 0) {\n theta = pi2 - theta;\n }\n this.theta = theta;\n this.phi = phi;\n }\n\n onBind() {\n return;\n }\n\n onEnd() {\n return;\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n if (this.phi == null || this.theta == null) {\n return;\n }\n const { center, r, cb } = typeof this.params === 'function' ? this.params() : this.params;\n const deltaAngle = Math.PI * 2 * ratio;\n const theta = this.theta + deltaAngle;\n const phi = this.phi;\n const x = r * Math.sin(phi) * Math.cos(theta) + center.x;\n const y = r * Math.cos(phi) + center.y;\n const z = r * Math.sin(phi) * Math.sin(theta) + center.z;\n out.x = x;\n out.y = y;\n out.z = z;\n // out.beta = phi;\n out.alpha = theta + pi / 2;\n while (out.alpha > pi2) {\n out.alpha -= pi2;\n }\n out.alpha = pi2 - out.alpha;\n\n out.zIndex = out.z * -10000;\n\n cb && cb(out);\n }\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { EasingType } from '../intreface/easing';
|
|
2
|
+
import { ACustomAnimate } from './custom-animate';
|
|
3
|
+
export interface IUpdateAnimationOptions {
|
|
4
|
+
diffAttrs: Record<string, any>;
|
|
5
|
+
animationState: string;
|
|
6
|
+
diffState: string;
|
|
7
|
+
data: Record<string, any>[];
|
|
8
|
+
}
|
|
9
|
+
export declare class State extends ACustomAnimate<Record<string, number>> {
|
|
10
|
+
valid: boolean;
|
|
11
|
+
constructor(from: null, to: null, duration: number, easing: EasingType, params?: IUpdateAnimationOptions);
|
|
12
|
+
update(end: boolean, ratio: number, out: Record<string, any>): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ACustomAnimate } from "./custom-animate";
|
|
2
|
+
|
|
3
|
+
export class State extends ACustomAnimate {
|
|
4
|
+
constructor(from, to, duration, easing, params) {
|
|
5
|
+
super(from, to, duration, easing, params);
|
|
6
|
+
}
|
|
7
|
+
update(end, ratio, out) {
|
|
8
|
+
if (this.onStart(), !this.props || !this.propKeys) return;
|
|
9
|
+
const easedRatio = this.easing(ratio);
|
|
10
|
+
this.animate.interpolateUpdateFunction ? this.animate.interpolateUpdateFunction(this.fromProps, this.props, easedRatio, this, this.target) : this.interpolateUpdateFunctions.forEach(((func, index) => {
|
|
11
|
+
if (!this.animate.validAttr(this.propKeys[index])) return;
|
|
12
|
+
const key = this.propKeys[index];
|
|
13
|
+
func(key, this.fromProps[key], this.props[key], easedRatio, this, this.target);
|
|
14
|
+
})), this.onUpdate(end, easedRatio, out);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/custom/state.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAclD,MAAM,OAAO,KAAM,SAAQ,cAAsC;IAG/D,YAAY,IAAU,EAAE,EAAQ,EAAE,QAAgB,EAAE,MAAkB,EAAE,MAAgC;QACtG,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5C,CAAC;IAED,MAAM,CAAC,GAAY,EAAE,KAAa,EAAE,GAAwB;QAC1D,IAAI,CAAC,OAAO,EAAE,CAAC;QACf,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YACjC,OAAO;SACR;QAED,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACtC,IAAI,CAAC,OAAO,CAAC,yBAAyB;YACpC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,yBAAyB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC;YACnG,CAAC,CAAC,IAAI,CAAC,0BAA0B,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;gBAEtD,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE;oBACjD,OAAO;iBACR;gBACD,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;gBACjC,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;gBACtC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBAChC,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;YAC/D,CAAC,CAAC,CAAC;QACP,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC;IACtC,CAAC;CACF","file":"state.js","sourcesContent":["import type { IAnimate, IStep } from '../intreface/animate';\nimport type { EasingType } from '../intreface/easing';\nimport { ACustomAnimate } from './custom-animate';\n\nexport interface IUpdateAnimationOptions {\n diffAttrs: Record<string, any>;\n animationState: string;\n diffState: string;\n data: Record<string, any>[];\n}\n\n/**\n * 文本输入动画,实现类似打字机的字符逐个显示效果\n * 支持通过beforeText和afterText参数添加前缀和后缀\n * 支持通过showCursor参数显示光标,cursorChar自定义光标字符\n */\nexport class State extends ACustomAnimate<Record<string, number>> {\n declare valid: boolean;\n\n constructor(from: null, to: null, duration: number, easing: EasingType, params?: IUpdateAnimationOptions) {\n super(from, to, duration, easing, params);\n }\n\n update(end: boolean, ratio: number, out: Record<string, any>): void {\n this.onStart();\n if (!this.props || !this.propKeys) {\n return;\n }\n // 应用缓动函数\n const easedRatio = this.easing(ratio);\n this.animate.interpolateUpdateFunction\n ? this.animate.interpolateUpdateFunction(this.fromProps, this.props, easedRatio, this, this.target)\n : this.interpolateUpdateFunctions.forEach((func, index) => {\n // 如果这个属性被屏蔽了,直接跳过\n if (!this.animate.validAttr(this.propKeys[index])) {\n return;\n }\n const key = this.propKeys[index];\n const fromValue = this.fromProps[key];\n const toValue = this.props[key];\n func(key, fromValue, toValue, easedRatio, this, this.target);\n });\n this.onUpdate(end, easedRatio, out);\n }\n}\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { IPointLike } from '@visactor/vutils';
|
|
2
|
+
import { ACustomAnimate } from './custom-animate';
|
|
3
|
+
import type { ISegment } from '@visactor/vrender-core';
|
|
4
|
+
import type { EasingType } from '../intreface/easing';
|
|
5
|
+
export declare class TagPointsUpdate extends ACustomAnimate<{
|
|
6
|
+
points?: IPointLike[];
|
|
7
|
+
segments?: ISegment[];
|
|
8
|
+
}> {
|
|
9
|
+
protected fromPoints: IPointLike[];
|
|
10
|
+
protected toPoints: IPointLike[];
|
|
11
|
+
protected points: IPointLike[];
|
|
12
|
+
protected interpolatePoints: [IPointLike, IPointLike][];
|
|
13
|
+
protected newPointAnimateType: 'grow' | 'appear' | 'clip';
|
|
14
|
+
protected clipRange: number;
|
|
15
|
+
protected shrinkClipRange: number;
|
|
16
|
+
protected clipRangeByDimension: 'x' | 'y';
|
|
17
|
+
protected segmentsCache: number[];
|
|
18
|
+
constructor(from: any, to: any, duration: number, easing: EasingType, params?: {
|
|
19
|
+
newPointAnimateType?: 'grow' | 'appear' | 'clip';
|
|
20
|
+
clipRangeByDimension?: 'x' | 'y';
|
|
21
|
+
});
|
|
22
|
+
private getPoints;
|
|
23
|
+
onBind(): void;
|
|
24
|
+
onFirstRun(): void;
|
|
25
|
+
onUpdate(end: boolean, ratio: number, out: Record<string, any>): void;
|
|
26
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { clamp, isValidNumber, Point } from "@visactor/vutils";
|
|
2
|
+
|
|
3
|
+
import { ACustomAnimate } from "./custom-animate";
|
|
4
|
+
|
|
5
|
+
import { pointInterpolation } from "@visactor/vrender-core";
|
|
6
|
+
|
|
7
|
+
export class TagPointsUpdate extends ACustomAnimate {
|
|
8
|
+
constructor(from, to, duration, easing, params) {
|
|
9
|
+
var _a, _b;
|
|
10
|
+
super(from, to, duration, easing, params), this.newPointAnimateType = null !== (_a = null == params ? void 0 : params.newPointAnimateType) && void 0 !== _a ? _a : "grow",
|
|
11
|
+
this.clipRangeByDimension = null !== (_b = null == params ? void 0 : params.clipRangeByDimension) && void 0 !== _b ? _b : "x";
|
|
12
|
+
}
|
|
13
|
+
getPoints(attribute, cache = !1) {
|
|
14
|
+
if (attribute.points) return attribute.points;
|
|
15
|
+
if (attribute.segments) {
|
|
16
|
+
const points = [];
|
|
17
|
+
return this.segmentsCache || (this.segmentsCache = []), attribute.segments.map((segment => {
|
|
18
|
+
var _a, _b;
|
|
19
|
+
segment.points && points.push(...segment.points), cache && this.segmentsCache.push(null !== (_b = null === (_a = segment.points) || void 0 === _a ? void 0 : _a.length) && void 0 !== _b ? _b : 0);
|
|
20
|
+
})), points;
|
|
21
|
+
}
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
onBind() {
|
|
25
|
+
const originFromPoints = this.getPoints(this.from), originToPoints = this.getPoints(this.to, !0);
|
|
26
|
+
this.fromPoints = originFromPoints ? Array.isArray(originFromPoints) ? originFromPoints : [ originFromPoints ] : [],
|
|
27
|
+
this.toPoints = originToPoints ? Array.isArray(originToPoints) ? originToPoints : [ originToPoints ] : [];
|
|
28
|
+
const tagMap = new Map;
|
|
29
|
+
this.fromPoints.forEach((point => {
|
|
30
|
+
point.context && tagMap.set(point.context, point);
|
|
31
|
+
}));
|
|
32
|
+
let firstMatchedPoint, lastMatchedPoint, firstMatchedIndex = 1 / 0, lastMatchedIndex = -1 / 0;
|
|
33
|
+
for (let i = 0; i < this.toPoints.length; i += 1) if (tagMap.has(this.toPoints[i].context)) {
|
|
34
|
+
firstMatchedIndex = i, firstMatchedPoint = tagMap.get(this.toPoints[i].context);
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
for (let i = this.toPoints.length - 1; i >= 0; i -= 1) if (tagMap.has(this.toPoints[i].context)) {
|
|
38
|
+
lastMatchedIndex = i, lastMatchedPoint = tagMap.get(this.toPoints[i].context);
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
"clip" === this.newPointAnimateType && 0 !== this.toPoints.length && (Number.isFinite(lastMatchedIndex) ? (this.clipRange = this.toPoints[lastMatchedIndex][this.clipRangeByDimension] / this.toPoints[this.toPoints.length - 1][this.clipRangeByDimension],
|
|
42
|
+
1 === this.clipRange && (this.shrinkClipRange = this.toPoints[lastMatchedIndex][this.clipRangeByDimension] / this.fromPoints[this.fromPoints.length - 1][this.clipRangeByDimension]),
|
|
43
|
+
isValidNumber(this.clipRange) ? this.clipRange = clamp(this.clipRange, 0, 1) : this.clipRange = 0) : this.clipRange = 0);
|
|
44
|
+
let prevMatchedPoint = this.toPoints[0];
|
|
45
|
+
this.interpolatePoints = this.toPoints.map(((point, index) => {
|
|
46
|
+
const matchedPoint = tagMap.get(point.context);
|
|
47
|
+
return matchedPoint ? (prevMatchedPoint = matchedPoint, [ matchedPoint, point ]) : "appear" === this.newPointAnimateType || "clip" === this.newPointAnimateType ? [ point, point ] : index < firstMatchedIndex && firstMatchedPoint ? [ firstMatchedPoint, point ] : index > lastMatchedIndex && lastMatchedPoint ? [ lastMatchedPoint, point ] : [ prevMatchedPoint, point ];
|
|
48
|
+
})), this.points = this.interpolatePoints.map((interpolate => {
|
|
49
|
+
const fromPoint = interpolate[0], toPoint = interpolate[1], newPoint = new Point(fromPoint.x, fromPoint.y, fromPoint.x1, fromPoint.y1);
|
|
50
|
+
return newPoint.defined = toPoint.defined, newPoint.context = toPoint.context, newPoint;
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
onFirstRun() {
|
|
54
|
+
const lastClipRange = this.target.attribute.clipRange;
|
|
55
|
+
isValidNumber(lastClipRange * this.clipRange) && (this.clipRange *= lastClipRange);
|
|
56
|
+
}
|
|
57
|
+
onUpdate(end, ratio, out) {
|
|
58
|
+
if (this.points = this.points.map(((point, index) => {
|
|
59
|
+
const newPoint = pointInterpolation(this.interpolatePoints[index][0], this.interpolatePoints[index][1], ratio);
|
|
60
|
+
return newPoint.context = point.context, newPoint;
|
|
61
|
+
})), this.clipRange) {
|
|
62
|
+
if (this.shrinkClipRange) return void (end ? (out.points = this.toPoints, out.clipRange = 1) : (out.points = this.fromPoints,
|
|
63
|
+
out.clipRange = this.clipRange - (this.clipRange - this.shrinkClipRange) * ratio));
|
|
64
|
+
out.clipRange = this.clipRange + (1 - this.clipRange) * ratio;
|
|
65
|
+
}
|
|
66
|
+
if (this.segmentsCache && this.to.segments) {
|
|
67
|
+
let start = 0;
|
|
68
|
+
out.segments = this.to.segments.map(((segment, index) => {
|
|
69
|
+
const end = start + this.segmentsCache[index], points = this.points.slice(start, end);
|
|
70
|
+
return start = end, Object.assign(Object.assign({}, segment), {
|
|
71
|
+
points: points
|
|
72
|
+
});
|
|
73
|
+
}));
|
|
74
|
+
} else out.points = this.points;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=tag-points.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/custom/tag-points.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAG5D,MAAM,OAAO,eAAgB,SAAQ,cAAgE;IAWnG,YACE,IAAS,EACT,EAAO,EACP,QAAgB,EAChB,MAAkB,EAClB,MAA+F;;QAE/F,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QAC1C,IAAI,CAAC,mBAAmB,GAAG,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,mBAAmB,mCAAI,MAAM,CAAC;QACjE,IAAI,CAAC,oBAAoB,GAAG,MAAA,MAAM,aAAN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AC,GAAG,CAAC,CAAC,OAAY,EAAE,KAAU,EAAE,EAAE;gBAC/D,MAAM,GAAG,GAAG,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;gBAC9C,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;gBAC7C,KAAK,GAAG,GAAG,CAAC;gBACZ,uCACK,OAAO,KACV,MAAM,IACN;YACJ,CAAC,CAAC,CAAC;SACJ;aAAM;YACL,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;SAC1B;IACH,CAAC;CACF","file":"tag-points.js","sourcesContent":["import type { IPointLike } from '@visactor/vutils';\nimport { clamp, isValidNumber, Point } from '@visactor/vutils';\nimport { ACustomAnimate } from './custom-animate';\nimport type { ISegment } from '@visactor/vrender-core';\nimport { pointInterpolation } from '@visactor/vrender-core';\nimport type { EasingType } from '../intreface/easing';\n\nexport class TagPointsUpdate extends ACustomAnimate<{ points?: IPointLike[]; segments?: ISegment[] }> {\n protected fromPoints: IPointLike[];\n protected toPoints: IPointLike[];\n protected points: IPointLike[];\n protected interpolatePoints: [IPointLike, IPointLike][];\n protected newPointAnimateType: 'grow' | 'appear' | 'clip';\n protected clipRange: number;\n protected shrinkClipRange: number;\n protected clipRangeByDimension: 'x' | 'y';\n protected segmentsCache: number[];\n\n constructor(\n from: any,\n to: any,\n duration: number,\n easing: EasingType,\n params?: { newPointAnimateType?: 'grow' | 'appear' | 'clip'; clipRangeByDimension?: 'x' | 'y' }\n ) {\n super(from, to, duration, easing, params);\n this.newPointAnimateType = params?.newPointAnimateType ?? 'grow';\n this.clipRangeByDimension = params?.clipRangeByDimension ?? 'x';\n }\n\n private getPoints(attribute: typeof this.from, cache = false): IPointLike[] {\n if (attribute.points) {\n return attribute.points;\n }\n\n if (attribute.segments) {\n const points = [] as IPointLike[];\n if (!this.segmentsCache) {\n this.segmentsCache = [];\n }\n attribute.segments.map((segment: any) => {\n if (segment.points) {\n points.push(...segment.points);\n }\n if (cache) {\n this.segmentsCache.push(segment.points?.length ?? 0);\n }\n });\n return points;\n }\n return [];\n }\n\n onBind(): void {\n const originFromPoints = this.getPoints(this.from);\n const originToPoints = this.getPoints(this.to, true);\n this.fromPoints = !originFromPoints ? [] : !Array.isArray(originFromPoints) ? [originFromPoints] : originFromPoints;\n this.toPoints = !originToPoints ? [] : !Array.isArray(originToPoints) ? [originToPoints] : originToPoints;\n\n const tagMap = new Map<string, IPointLike>();\n this.fromPoints.forEach(point => {\n if (point.context) {\n tagMap.set(point.context, point);\n }\n });\n let firstMatchedIndex = Infinity;\n let lastMatchedIndex = -Infinity;\n let firstMatchedPoint: IPointLike;\n let lastMatchedPoint: IPointLike;\n for (let i = 0; i < this.toPoints.length; i += 1) {\n if (tagMap.has(this.toPoints[i].context)) {\n firstMatchedIndex = i;\n firstMatchedPoint = tagMap.get(this.toPoints[i].context);\n break;\n }\n }\n for (let i = this.toPoints.length - 1; i >= 0; i -= 1) {\n if (tagMap.has(this.toPoints[i].context)) {\n lastMatchedIndex = i;\n lastMatchedPoint = tagMap.get(this.toPoints[i].context);\n break;\n }\n }\n\n if (this.newPointAnimateType === 'clip') {\n if (this.toPoints.length !== 0) {\n if (Number.isFinite(lastMatchedIndex)) {\n this.clipRange =\n this.toPoints[lastMatchedIndex][this.clipRangeByDimension] /\n this.toPoints[this.toPoints.length - 1][this.clipRangeByDimension];\n if (this.clipRange === 1) {\n this.shrinkClipRange =\n this.toPoints[lastMatchedIndex][this.clipRangeByDimension] /\n this.fromPoints[this.fromPoints.length - 1][this.clipRangeByDimension];\n }\n if (!isValidNumber(this.clipRange)) {\n this.clipRange = 0;\n } else {\n this.clipRange = clamp(this.clipRange, 0, 1);\n }\n } else {\n this.clipRange = 0;\n }\n }\n }\n // TODO: shrink removed points\n // if no point is matched, animation should start from toPoint[0]\n let prevMatchedPoint = this.toPoints[0];\n this.interpolatePoints = this.toPoints.map((point, index) => {\n const matchedPoint = tagMap.get(point.context);\n if (matchedPoint) {\n prevMatchedPoint = matchedPoint;\n return [matchedPoint, point];\n }\n // appear new point\n if (this.newPointAnimateType === 'appear' || this.newPointAnimateType === 'clip') {\n return [point, point];\n }\n // grow new point\n if (index < firstMatchedIndex && firstMatchedPoint) {\n return [firstMatchedPoint, point];\n } else if (index > lastMatchedIndex && lastMatchedPoint) {\n return [lastMatchedPoint, point];\n }\n return [prevMatchedPoint, point];\n });\n this.points = this.interpolatePoints.map(interpolate => {\n const fromPoint = interpolate[0];\n const toPoint = interpolate[1];\n const newPoint = new Point(fromPoint.x, fromPoint.y, fromPoint.x1, fromPoint.y1);\n newPoint.defined = toPoint.defined;\n newPoint.context = toPoint.context;\n return newPoint;\n });\n }\n\n onFirstRun(): void {\n const lastClipRange = (this.target.attribute as any).clipRange;\n if (isValidNumber(lastClipRange * this.clipRange)) {\n this.clipRange *= lastClipRange;\n }\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n // if not create new points, multi points animation might not work well.\n this.points = this.points.map((point, index) => {\n const newPoint = pointInterpolation(this.interpolatePoints[index][0], this.interpolatePoints[index][1], ratio);\n newPoint.context = point.context;\n return newPoint;\n });\n if (this.clipRange) {\n if (this.shrinkClipRange) {\n // 折线变短\n if (!end) {\n out.points = this.fromPoints;\n out.clipRange = this.clipRange - (this.clipRange - this.shrinkClipRange) * ratio;\n } else {\n out.points = this.toPoints;\n out.clipRange = 1;\n }\n return;\n }\n out.clipRange = this.clipRange + (1 - this.clipRange) * ratio;\n }\n if (this.segmentsCache && this.to.segments) {\n let start = 0;\n out.segments = this.to.segments.map((segment: any, index: any) => {\n const end = start + this.segmentsCache[index];\n const points = this.points.slice(start, end);\n start = end;\n return {\n ...segment,\n points\n };\n });\n } else {\n out.points = this.points;\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { EasingType } from '../intreface/easing';
|
|
2
|
+
import { ACustomAnimate } from './custom-animate';
|
|
3
|
+
export interface IUpdateAnimationOptions {
|
|
4
|
+
diffAttrs: Record<string, any>;
|
|
5
|
+
animationState: string;
|
|
6
|
+
diffState: string;
|
|
7
|
+
data: Record<string, any>[];
|
|
8
|
+
}
|
|
9
|
+
export declare class Update extends ACustomAnimate<Record<string, number>> {
|
|
10
|
+
valid: boolean;
|
|
11
|
+
params: IUpdateAnimationOptions;
|
|
12
|
+
constructor(from: null, to: null, duration: number, easing: EasingType, params?: IUpdateAnimationOptions);
|
|
13
|
+
update(end: boolean, ratio: number, out: Record<string, any>): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ACustomAnimate } from "./custom-animate";
|
|
2
|
+
|
|
3
|
+
export class Update extends ACustomAnimate {
|
|
4
|
+
constructor(from, to, duration, easing, params) {
|
|
5
|
+
const {diffAttrs: diffAttrs = {}} = params;
|
|
6
|
+
super(from, diffAttrs, duration, easing, params), this.params = params;
|
|
7
|
+
}
|
|
8
|
+
update(end, ratio, out) {
|
|
9
|
+
if (this.onStart(), !this.props || !this.propKeys) return;
|
|
10
|
+
const easedRatio = this.easing(ratio);
|
|
11
|
+
this.animate.interpolateUpdateFunction ? this.animate.interpolateUpdateFunction(this.fromProps, this.props, easedRatio, this, this.target) : this.interpolateUpdateFunctions.forEach(((func, index) => {
|
|
12
|
+
if (!this.animate.validAttr(this.propKeys[index])) return;
|
|
13
|
+
const key = this.propKeys[index];
|
|
14
|
+
func(key, this.fromProps[key], this.props[key], easedRatio, this, this.target);
|
|
15
|
+
})), this.onUpdate(end, easedRatio, out);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=update.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/custom/update.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAclD,MAAM,OAAO,MAAO,SAAQ,cAAsC;IAIhE,YAAY,IAAU,EAAE,EAAQ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AAI,CAAC,QAAQ,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC;IACtC,CAAC;CACF","file":"update.js","sourcesContent":["import type { IAnimate, IStep } from '../intreface/animate';\nimport type { EasingType } from '../intreface/easing';\nimport { ACustomAnimate } from './custom-animate';\n\nexport interface IUpdateAnimationOptions {\n diffAttrs: Record<string, any>;\n animationState: string;\n diffState: string;\n data: Record<string, any>[];\n}\n\n/**\n * 文本输入动画,实现类似打字机的字符逐个显示效果\n * 支持通过beforeText和afterText参数添加前缀和后缀\n * 支持通过showCursor参数显示光标,cursorChar自定义光标字符\n */\nexport class Update extends ACustomAnimate<Record<string, number>> {\n declare valid: boolean;\n params: IUpdateAnimationOptions;\n\n constructor(from: null, to: null, duration: number, easing: EasingType, params?: IUpdateAnimationOptions) {\n const { diffAttrs = {} } = params;\n super(from, diffAttrs, duration, easing, params);\n this.params = params;\n }\n\n update(end: boolean, ratio: number, out: Record<string, any>): void {\n this.onStart();\n if (!this.props || !this.propKeys) {\n return;\n }\n // 应用缓动函数\n const easedRatio = this.easing(ratio);\n this.animate.interpolateUpdateFunction\n ? this.animate.interpolateUpdateFunction(this.fromProps, this.props, easedRatio, this, this.target)\n : this.interpolateUpdateFunctions.forEach((func, index) => {\n // 如果这个属性被屏蔽了,直接跳过\n if (!this.animate.validAttr(this.propKeys[index])) {\n return;\n }\n const key = this.propKeys[index];\n const fromValue = this.fromProps[key];\n const toValue = this.props[key];\n func(key, fromValue, toValue, easedRatio, this, this.target);\n });\n this.onUpdate(end, easedRatio, out);\n }\n}\n"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { IGraphic } from '@visactor/vrender-core';
|
|
2
|
+
import type { IAnimationConfig, IAnimationCustomConstructor } from './executor';
|
|
3
|
+
import type { IAnimate } from '../intreface/animate';
|
|
4
|
+
interface IAnimateExecutor {
|
|
5
|
+
execute: (params: IAnimationConfig) => void;
|
|
6
|
+
executeItem: (params: IAnimationConfig, graphic: IGraphic, index?: number) => IAnimate | null;
|
|
7
|
+
onStart: (cb?: () => void) => void;
|
|
8
|
+
onEnd: (cb?: () => void) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare class AnimateExecutor implements IAnimateExecutor {
|
|
11
|
+
static builtInAnimateMap: Record<string, IAnimationCustomConstructor>;
|
|
12
|
+
static registerBuiltInAnimate(name: string, animate: IAnimationCustomConstructor): void;
|
|
13
|
+
_target: IGraphic;
|
|
14
|
+
private _animates;
|
|
15
|
+
private _startCallbacks;
|
|
16
|
+
private _endCallbacks;
|
|
17
|
+
private _started;
|
|
18
|
+
private _activeCount;
|
|
19
|
+
constructor(target: IGraphic);
|
|
20
|
+
onStart(cb?: () => void): void;
|
|
21
|
+
onEnd(cb?: () => void): void;
|
|
22
|
+
private _trackAnimation;
|
|
23
|
+
parseParams(params: IAnimationConfig): IAnimationConfig;
|
|
24
|
+
execute(params: IAnimationConfig): void;
|
|
25
|
+
private executeTypeConfigItem;
|
|
26
|
+
private _handleRunAnimate;
|
|
27
|
+
private executeTimelineItem;
|
|
28
|
+
private applyTimeSliceToAnimate;
|
|
29
|
+
private createCustomInterpolatorAnimation;
|
|
30
|
+
private createCustomAnimation;
|
|
31
|
+
private createPropsFromChannel;
|
|
32
|
+
private resolveValue;
|
|
33
|
+
executeItem(params: IAnimationConfig, graphic: IGraphic, index?: number, count?: number): IAnimate | null;
|
|
34
|
+
stop(type?: 'start' | 'end' | Record<string, any>): void;
|
|
35
|
+
}
|
|
36
|
+
export {};
|