@ssgoi/core 6.0.0 → 6.1.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.
Files changed (99) hide show
  1. package/README.md +5 -6
  2. package/dist/animation/animation.d.ts +18 -0
  3. package/dist/animation/animation.d.ts.map +1 -1
  4. package/dist/animation/host-animation.d.ts +2 -0
  5. package/dist/animation/host-animation.d.ts.map +1 -1
  6. package/dist/animation/multi-animation.d.ts +20 -4
  7. package/dist/animation/multi-animation.d.ts.map +1 -1
  8. package/dist/animation/web-animation.d.ts +2 -0
  9. package/dist/animation/web-animation.d.ts.map +1 -1
  10. package/dist/index.cjs +10 -10
  11. package/dist/index.js +998 -561
  12. package/dist/internal.cjs +1 -1
  13. package/dist/internal.js +208 -201
  14. package/dist/multi-animation-CnxqLEka.js +322 -0
  15. package/dist/multi-animation-Dw2JTJI2.cjs +1 -0
  16. package/dist/ssgoi-transition/create-ssgoi-transition-context.d.ts.map +1 -1
  17. package/dist/transitions/axis/index.d.ts +43 -0
  18. package/dist/transitions/axis/index.d.ts.map +1 -0
  19. package/dist/transitions/axis/provider/index.d.ts +8 -0
  20. package/dist/transitions/axis/provider/index.d.ts.map +1 -0
  21. package/dist/transitions/axis/provider/x/fluid.d.ts +3 -0
  22. package/dist/transitions/axis/provider/x/fluid.d.ts.map +1 -0
  23. package/dist/transitions/axis/provider/x/index.d.ts +3 -0
  24. package/dist/transitions/axis/provider/x/index.d.ts.map +1 -0
  25. package/dist/transitions/axis/provider/x/snappy.d.ts +3 -0
  26. package/dist/transitions/axis/provider/x/snappy.d.ts.map +1 -0
  27. package/dist/transitions/axis/provider/y.d.ts +3 -0
  28. package/dist/transitions/axis/provider/y.d.ts.map +1 -0
  29. package/dist/transitions/axis/provider/z.d.ts +3 -0
  30. package/dist/transitions/axis/provider/z.d.ts.map +1 -0
  31. package/dist/transitions/axis/transition.d.ts +5 -0
  32. package/dist/transitions/axis/transition.d.ts.map +1 -0
  33. package/dist/transitions/axis/types.d.ts +52 -0
  34. package/dist/transitions/axis/types.d.ts.map +1 -0
  35. package/dist/transitions/blind/index.d.ts +10 -1
  36. package/dist/transitions/blind/index.d.ts.map +1 -1
  37. package/dist/transitions/drill/index.d.ts +37 -6
  38. package/dist/transitions/drill/index.d.ts.map +1 -1
  39. package/dist/transitions/drill/types.d.ts +10 -0
  40. package/dist/transitions/drill/types.d.ts.map +1 -1
  41. package/dist/transitions/fade/index.d.ts +13 -3
  42. package/dist/transitions/fade/index.d.ts.map +1 -1
  43. package/dist/transitions/fade/types.d.ts +14 -0
  44. package/dist/transitions/fade/types.d.ts.map +1 -0
  45. package/dist/transitions/film/index.d.ts +13 -3
  46. package/dist/transitions/film/index.d.ts.map +1 -1
  47. package/dist/transitions/film/types.d.ts +16 -0
  48. package/dist/transitions/film/types.d.ts.map +1 -0
  49. package/dist/transitions/hero/index.d.ts +14 -3
  50. package/dist/transitions/hero/index.d.ts.map +1 -1
  51. package/dist/transitions/hero/types.d.ts +12 -0
  52. package/dist/transitions/hero/types.d.ts.map +1 -0
  53. package/dist/transitions/index.d.ts +1 -0
  54. package/dist/transitions/index.d.ts.map +1 -1
  55. package/dist/transitions/jaemin/index.d.ts +13 -3
  56. package/dist/transitions/jaemin/index.d.ts.map +1 -1
  57. package/dist/transitions/jaemin/types.d.ts +9 -0
  58. package/dist/transitions/jaemin/types.d.ts.map +1 -0
  59. package/dist/transitions/rotate/index.d.ts +12 -3
  60. package/dist/transitions/rotate/index.d.ts.map +1 -1
  61. package/dist/transitions/rotate/types.d.ts +9 -0
  62. package/dist/transitions/rotate/types.d.ts.map +1 -0
  63. package/dist/transitions/scroll/index.d.ts +7 -7
  64. package/dist/transitions/scroll/index.d.ts.map +1 -1
  65. package/dist/transitions/sheet/index.d.ts +38 -6
  66. package/dist/transitions/sheet/index.d.ts.map +1 -1
  67. package/dist/transitions/sheet/types.d.ts +10 -0
  68. package/dist/transitions/sheet/types.d.ts.map +1 -1
  69. package/dist/transitions/slide/index.d.ts +13 -3
  70. package/dist/transitions/slide/index.d.ts.map +1 -1
  71. package/dist/transitions/slide/types.d.ts +10 -0
  72. package/dist/transitions/slide/types.d.ts.map +1 -0
  73. package/dist/transitions/strip/index.d.ts +13 -3
  74. package/dist/transitions/strip/index.d.ts.map +1 -1
  75. package/dist/transitions/strip/types.d.ts +9 -0
  76. package/dist/transitions/strip/types.d.ts.map +1 -0
  77. package/dist/transitions/utils.d.ts +16 -0
  78. package/dist/transitions/utils.d.ts.map +1 -1
  79. package/dist/transitions/zoom/index.d.ts +17 -3
  80. package/dist/transitions/zoom/index.d.ts.map +1 -1
  81. package/dist/transitions/zoom/provider/blur.d.ts +14 -0
  82. package/dist/transitions/zoom/provider/blur.d.ts.map +1 -0
  83. package/dist/transitions/zoom/provider/expand.d.ts +6 -1
  84. package/dist/transitions/zoom/provider/expand.d.ts.map +1 -1
  85. package/dist/transitions/zoom/provider/index.d.ts +10 -1
  86. package/dist/transitions/zoom/provider/index.d.ts.map +1 -1
  87. package/dist/transitions/zoom/provider/static.d.ts +6 -1
  88. package/dist/transitions/zoom/provider/static.d.ts.map +1 -1
  89. package/dist/transitions/zoom/transition.d.ts +3 -3
  90. package/dist/transitions/zoom/transition.d.ts.map +1 -1
  91. package/dist/transitions/zoom/types.d.ts +78 -3
  92. package/dist/transitions/zoom/types.d.ts.map +1 -1
  93. package/dist/transitions/zoom/zoom-element.d.ts +2 -2
  94. package/dist/transitions/zoom/zoom-element.d.ts.map +1 -1
  95. package/dist/types/index.d.ts +3 -4
  96. package/dist/types/index.d.ts.map +1 -1
  97. package/package.json +1 -1
  98. package/dist/multi-animation-B_Hl1HEU.cjs +0 -1
  99. package/dist/multi-animation-CST6aZ8y.js +0 -276
@@ -1,8 +1,10 @@
1
1
  import { PhysicsOptions } from '../../types/index.ts';
2
- export type ZoomType = "expand" | "static";
3
- export interface ZoomOptions {
2
+ import { Animation } from '../../animation';
3
+ export type ZoomType = "expand" | "static" | "blur";
4
+ export type ZoomVariant = "default" | "fade";
5
+ export interface NormalizedZoomOptions {
4
6
  type: ZoomType;
5
- timeout?: number;
7
+ variant: ZoomVariant;
6
8
  }
7
9
  export type ZoomStyleObject = Record<string, string>;
8
10
  export type ZoomAnimationFunc = (progress: number) => ZoomStyleObject;
@@ -18,6 +20,13 @@ export interface ZoomAnimationInput {
18
20
  x: number;
19
21
  y: number;
20
22
  };
23
+ enterRadius: number;
24
+ exitRadius: number;
25
+ }
26
+ export interface ZoomOverlayConfig {
27
+ willChange: string;
28
+ initialStyle: Record<string, string>;
29
+ style: (mode: "enter" | "exit", progress: number) => Record<string, string | number>;
21
30
  }
22
31
  export interface ZoomProvider {
23
32
  physics: PhysicsOptions;
@@ -25,10 +34,76 @@ export interface ZoomProvider {
25
34
  out: (input: ZoomAnimationInput) => ZoomAnimationConfig;
26
35
  backgroundIn: (input: ZoomAnimationInput) => ZoomAnimationConfig;
27
36
  backgroundOut: (input: ZoomAnimationInput) => ZoomAnimationConfig;
37
+ overlay?: ZoomOverlayConfig;
28
38
  }
29
39
  export interface ZoomAnimationHandlers {
30
40
  mode: "enter" | "exit";
31
41
  inAnimation?: ZoomAnimationFunc;
32
42
  outAnimation?: ZoomAnimationFunc;
33
43
  }
44
+ /**
45
+ * Resolution result handed to every strategy: which side initiated the zoom
46
+ * and the two DOM nodes whose rects drive the math.
47
+ */
48
+ export interface ZoomResolved {
49
+ mode: "enter" | "exit";
50
+ enterEl: HTMLElement;
51
+ exitEl: HTMLElement;
52
+ }
53
+ /**
54
+ * Mutable extras pool. Strategies fill in their own slots during `prepare`
55
+ * and read from a shared bag in `contribute`, which keeps the dispatcher
56
+ * agnostic to which slot belongs to which strategy.
57
+ */
58
+ export interface ZoomExtras {
59
+ overlay?: HTMLElement;
60
+ }
61
+ /**
62
+ * Arguments passed to `prepare`. The strategy can `from.then(el => …)` to
63
+ * attach styles ahead of layout, or create DOM via `createElement`.
64
+ */
65
+ export interface ZoomPrepareCtx {
66
+ from: Promise<HTMLElement>;
67
+ to: Promise<HTMLElement>;
68
+ context: {
69
+ positionedParent: HTMLElement;
70
+ };
71
+ createElement: <K extends keyof HTMLElementTagNameMap>(id: string, tag?: K) => K extends keyof HTMLElementTagNameMap ? HTMLElementTagNameMap[K] : HTMLDivElement;
72
+ }
73
+ /**
74
+ * Inputs each strategy receives at `contribute` time. `physics` is sourced
75
+ * from the BackgroundStrategy that owns the active `type` and is reused by
76
+ * every other strategy so progress is locked.
77
+ */
78
+ export interface ZoomContributeCtx {
79
+ from: HTMLElement;
80
+ to: HTMLElement;
81
+ resolved: ZoomResolved;
82
+ input: ZoomAnimationInput;
83
+ physics: PhysicsOptions;
84
+ extras: ZoomExtras;
85
+ /**
86
+ * Mutation registry. Strategies push restore callbacks here; the
87
+ * dispatcher fires them on completion. Keeps cleanup local to each
88
+ * strategy instead of leaking back into the dispatcher.
89
+ */
90
+ onComplete: (fn: () => void) => void;
91
+ }
92
+ /**
93
+ * Strategy interface. Both methods are optional — a no-op strategy is
94
+ * a legitimate factory return value (e.g. `FadeStrategy.forVariant("default")`).
95
+ */
96
+ export interface ZoomStrategy {
97
+ /**
98
+ * Pre-paint setup. May mutate the outgoing/incoming pages via the
99
+ * promises in `ctx`, or stage DOM via `createElement`. Returns extras
100
+ * that get merged into the shared `ZoomExtras` bag.
101
+ */
102
+ prepare?: (ctx: ZoomPrepareCtx) => Partial<ZoomExtras> | void;
103
+ /**
104
+ * Build the strategy's contribution to the final animation list. Called
105
+ * once per transition with both pages resolved and rect math complete.
106
+ */
107
+ contribute?: (ctx: ZoomContributeCtx) => Animation[];
108
+ }
34
109
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/transitions/zoom/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAE7C,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE3C,MAAM,WAAW,WAA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O,CAAC,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,OAAO,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;IAE9D;;;OAGG;IACH,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,iBAAiB,KAAK,SAAS,EAAE,CAAC;CACtD"}
@@ -1,4 +1,4 @@
1
1
  import { ZoomAnimationConfig, ZoomAnimationInput } from './types';
2
- export declare function createZoomIn({ enterRect, exitRect, pageRect, scrollOffset, }: ZoomAnimationInput): ZoomAnimationConfig;
3
- export declare function createZoomOut({ enterRect, exitRect, pageRect, scrollOffset, }: ZoomAnimationInput): ZoomAnimationConfig;
2
+ export declare function createZoomIn({ enterRect, exitRect, pageRect, scrollOffset, enterRadius, exitRadius, }: ZoomAnimationInput): ZoomAnimationConfig;
3
+ export declare function createZoomOut({ enterRect, exitRect, pageRect, scrollOffset, enterRadius, exitRadius, }: ZoomAnimationInput): ZoomAnimationConfig;
4
4
  //# sourceMappingURL=zoom-element.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"zoom-element.d.ts","sourceRoot":"","sources":["../../../src/lib/transitions/zoom/zoom-element.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAEvE,wBAAgB,YAAY,CAAC,EAC3B,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,YAAY,GACb,EAAE,kBAAkB,GAAG,mBAAmB,CAoC1C;AAED,wBAAgB,aAAa,CAAC,EAC5B,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,YAAY,GACb,EAAE,kBAAkB,GAAG,mBAAmB,CAoC1C"}
1
+ {"version":3,"file":"zoom-element.d.ts","sourceRoot":"","sources":["../../../src/lib/transitions/zoom/zoom-element.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAEvE,wBAAgB,YAAY,CAAC,EAC3B,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,UAAU,GACX,EAAE,kBAAkB,GAAG,mBAAmB,CAyC1C;AAED,wBAAgB,aAAa,CAAC,EAC5B,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,UAAU,GACX,EAAE,kBAAkB,GAAG,mBAAmB,CAuC1C"}
@@ -121,9 +121,9 @@ export type TransitionConfig<TExtras extends object = object> = {
121
121
  animation: (args: AnimationFactoryArgs<TExtras>) => Animation;
122
122
  };
123
123
  /**
124
- * Erased-extras form used at storage boundaries (path config, default
125
- * transition). The dispatcher passes whatever prepare returned to animation
126
- * verbatim, so we can treat the extras as opaque here.
124
+ * Erased-extras form used at path config storage boundaries. The dispatcher
125
+ * passes whatever prepare returned to animation verbatim, so we can treat the
126
+ * extras as opaque here.
127
127
  */
128
128
  export type AnyTransitionConfig = TransitionConfig<any>;
129
129
  export type SsgoiPathTransition = {
@@ -144,7 +144,6 @@ export type PreserveScrollFn = (isMobile: boolean) => PreserveScrollValue;
144
144
  export type PreserveScrollOption = PreserveScrollValue | PreserveScrollFn;
145
145
  export type SsgoiConfig = {
146
146
  transitions?: readonly SsgoiPathTransitionInput[];
147
- defaultTransition?: AnyTransitionConfig;
148
147
  middleware?: (from: string, to: string) => {
149
148
  from: string;
150
149
  to: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAMxD,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;AAM1D,MAAM,MAAM,0BAA0B,GAAG;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MA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BAAwB,GAChC,mBAAmB,GACnB,SAAS,wBAAwB,EAAE,CAAC;AAExC,MAAM,MAAM,mBAAmB,GAC3B,OAAO,GACP;IAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GACnC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AACxC,MAAM,MAAM,gBAAgB,GAAG,CAAC,QAAQ,EAAE,OAAO,KAAK,mBAAmB,CAAC;AAC1E,MAAM,MAAM,oBAAoB,GAAG,mBAAmB,GAAG,gBAAgB,CAAC;AAE1E,MAAM,MAAM,WAAW,GAAG;IACxB,WAAW,CAAC,EAAE,SAAS,wBAAwB,EAAE,CAAC;IAClD,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IACxE,cAAc,CAAC,EAAE,oBAAoB,CAAC;CACvC,CAAC;AASF;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB;;;;;OAKG;IACH,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,KAAK,IAAI,CAAC;IAEvD;;;;OAIG;IACH,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAC;CACjE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ssgoi/core",
3
- "version": "6.0.0",
3
+ "version": "6.1.0",
4
4
  "description": "Core animation engine for SSGOI - Native app-like page transitions with spring physics",
5
5
  "private": false,
6
6
  "type": "module",
@@ -1 +0,0 @@
1
- "use strict";var f=Object.defineProperty;var y=(r,l,e)=>l in r?f(r,l,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[l]=e;var s=(r,l,e)=>y(r,typeof l!="symbol"?l+"":l,e);class p{constructor(){s(this,"_playbackRate",1);s(this,"onUpdate");s(this,"onComplete")}get playbackRate(){return this._playbackRate}set playbackRate(l){this._playbackRate=l}}const g=.01,v=.01,m=.05,c=1e3/60;class R extends p{constructor(e){super();s(this,"element");s(this,"integrator");s(this,"styleFn");s(this,"lowerBound");s(this,"upperBound");s(this,"currentValue");s(this,"currentVelocity",0);s(this,"frames",[]);s(this,"waapi",null);s(this,"startTime",0);s(this,"running",!1);s(this,"paused",!1);s(this,"settled",!1);s(this,"reversing",!1);this.element=e.element,this.integrator=e.integrator,this.styleFn=e.style,this.lowerBound=e.lowerBound??0,this.upperBound=e.upperBound??1,this.currentValue=this.lowerBound,this.onUpdate=e.onUpdate,this.onComplete=e.onComplete}play(){if(this.reversing=!1,this.paused&&this.waapi){this.paused=!1,this.running=!0,this.waapi.play();return}this.runToward(this.upperBound)}reverse(){this.reversing=!0,this.runToward(this.lowerBound)}pause(){var e;this.running&&(this.captureLiveState(),(e=this.waapi)==null||e.pause(),this.running=!1,this.paused=!0)}complete(){var e;this.clearWaapi(),this.running=!1,this.paused=!1,this.currentValue=this.upperBound,this.currentVelocity=0,this.applyStyleAt(this.currentValue),this.settled=!0,(e=this.onComplete)==null||e.call(this)}get isAnimating(){return this.running}get isPaused(){return this.paused}get isComplete(){return this.settled}get isReversing(){return this.reversing}get playbackRate(){return super.playbackRate}set playbackRate(e){super.playbackRate=e,this.waapi&&(this.waapi.playbackRate=e)}getPose(){return this.running&&this.captureLiveState(),[{element:this.element,value:this.currentValue,velocity:this.currentVelocity}]}getTimeline(){const e=this.frames.map(t=>{const i=t.position,n=this.lowerBound+this.upperBound-i;return{time:t.time,value:t.position,velocity:t.velocity,style:this.styleFn(i,n)}});return[{element:this.element,frames:e}]}matchInto(e){const t=e.find(i=>i.element===this.element);t&&(this.currentValue=t.value,this.currentVelocity=t.velocity)}runToward(e){var h;if(this.running&&this.captureLiveState(),this.clearWaapi(),this.running=!1,this.paused=!1,this.settled=!1,this.frames=w(this.integrator,this.currentValue,e,this.currentVelocity),this.frames.length===0){this.currentValue=e,this.currentVelocity=0,this.applyStyleAt(e),this.settled=!0,(h=this.onComplete)==null||h.call(this);return}const t=this.frames.map(o=>{const u=o.position,d=this.lowerBound+this.upperBound-u;return this.styleFn(u,d)}),i=t[0];if(i)for(const o of Object.keys(i))this.element.style[o]="";const n=this.frames[this.frames.length-1],a=n.time;this.waapi=this.element.animate(t,{duration:a,fill:"forwards",easing:"linear",composite:"replace"}),this.waapi.playbackRate=this.playbackRate,this.startTime=performance.now(),this.running=!0,this.waapi.onfinish=()=>{var o;this.running&&(this.running=!1,this.settled=!0,this.currentValue=n.position,this.currentVelocity=0,(o=this.onComplete)==null||o.call(this))}}clearWaapi(){var e;(e=this.waapi)==null||e.cancel(),this.waapi=null}captureLiveState(){if(this.frames.length===0)return;const e=performance.now()-this.startTime,{position:t,velocity:i}=C(this.frames,e);this.currentValue=t,this.currentVelocity=i}applyStyleAt(e){const t=this.lowerBound+this.upperBound-e,i=this.styleFn(e,t);for(const[n,a]of Object.entries(i))this.element.style[n]=typeof a=="number"?String(a):a}}function w(r,l,e,t){if(l===e&&t===0)return[];const i=600;let n={position:l,velocity:t},a=0;const h=[];for(let o=0;o<i;o++){const u=o*c;if(h.push({time:u,position:n.position,velocity:n.velocity}),n=r.step(n,e,c/1e3),r.isSettled(n,e)){if(a+=c/1e3,a>=m){h.push({time:(o+1)*c,position:e,velocity:0});break}}else a=0}return h}function C(r,l){if(r.length===0)return{position:0,velocity:0};const e=r[0],t=r[r.length-1];if(l<=0)return{position:e.position,velocity:e.velocity};if(l>=t.time)return{position:t.position,velocity:t.velocity};let i=0,n=r.length-1;for(;i<n-1;){const u=i+n>>1;r[u].time<=l?i=u:n=u}const a=r[i],h=r[n],o=(l-a.time)/(h.time-a.time);return{position:a.position+(h.position-a.position)*o,velocity:a.velocity+(h.velocity-a.velocity)*o}}class T extends p{constructor(e,t={}){super();s(this,"children");s(this,"mode");s(this,"pendingComplete",0);s(this,"running",!1);this.children=e,this.mode=t.mode??"parallel"}play(){this.running&&this.pause(),this.running=!0,this.mode==="parallel"?this.startParallel("play"):this.startSequence("play",0)}reverse(){this.running&&this.pause(),this.running=!0,this.mode==="parallel"?this.startParallel("reverse"):this.startSequence("reverse",0)}pause(){this.running=!1;for(const e of this.children)e.pause()}complete(){var e;this.running=!1;for(const t of this.children)t.complete();(e=this.onComplete)==null||e.call(this)}getPose(){return this.children.flatMap(e=>e.getPose())}getTimeline(){return this.children.flatMap(e=>e.getTimeline())}matchInto(e){}get isAnimating(){return this.children.some(e=>e.isAnimating)}get isPaused(){return this.children.some(e=>e.isPaused)&&this.children.every(e=>e.isPaused||e.isComplete)}get isComplete(){return this.children.every(e=>e.isComplete)}get isReversing(){return this.children.some(e=>e.isReversing)}get playbackRate(){return super.playbackRate}set playbackRate(e){super.playbackRate=e;for(const t of this.children)t.playbackRate=e}startParallel(e){if(this.pendingComplete=this.children.length,this.pendingComplete===0){this.handleFinished();return}for(const t of this.children){const i=t.onComplete;t.onComplete=()=>{i==null||i(),this.handleChildComplete()},t[e]()}}startSequence(e,t){if(!this.running)return;if(t>=this.children.length){this.handleFinished();return}const i=this.children[t],n=i.onComplete;i.onComplete=()=>{n==null||n(),this.startSequence(e,t+1)},i[e]()}handleChildComplete(){this.pendingComplete--,this.pendingComplete<=0&&this.handleFinished()}handleFinished(){var e;this.running=!1,(e=this.onComplete)==null||e.call(this)}}exports.Animation=p;exports.MultiAnimation=T;exports.POSITION_THRESHOLD=g;exports.SETTLE_THRESHOLD=m;exports.VELOCITY_THRESHOLD=v;exports.WebAnimation=R;
@@ -1,276 +0,0 @@
1
- var d = Object.defineProperty;
2
- var f = (r, l, e) => l in r ? d(r, l, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[l] = e;
3
- var s = (r, l, e) => f(r, typeof l != "symbol" ? l + "" : l, e);
4
- class p {
5
- constructor() {
6
- /** Current playback rate (1 = realtime, 0 = paused, negative = backwards) */
7
- s(this, "_playbackRate", 1);
8
- /** Fired every frame with the most recent value. Optional. */
9
- s(this, "onUpdate");
10
- /** Fired once when the animation settles. */
11
- s(this, "onComplete");
12
- }
13
- get playbackRate() {
14
- return this._playbackRate;
15
- }
16
- set playbackRate(l) {
17
- this._playbackRate = l;
18
- }
19
- }
20
- const R = 0.01, C = 0.01, y = 0.05, c = 1e3 / 60;
21
- class b extends p {
22
- constructor(e) {
23
- super();
24
- s(this, "element");
25
- s(this, "integrator");
26
- s(this, "styleFn");
27
- s(this, "lowerBound");
28
- s(this, "upperBound");
29
- s(this, "currentValue");
30
- s(this, "currentVelocity", 0);
31
- s(this, "frames", []);
32
- s(this, "waapi", null);
33
- s(this, "startTime", 0);
34
- s(this, "running", !1);
35
- s(this, "paused", !1);
36
- s(this, "settled", !1);
37
- s(this, "reversing", !1);
38
- this.element = e.element, this.integrator = e.integrator, this.styleFn = e.style, this.lowerBound = e.lowerBound ?? 0, this.upperBound = e.upperBound ?? 1, this.currentValue = this.lowerBound, this.onUpdate = e.onUpdate, this.onComplete = e.onComplete;
39
- }
40
- play() {
41
- if (this.reversing = !1, this.paused && this.waapi) {
42
- this.paused = !1, this.running = !0, this.waapi.play();
43
- return;
44
- }
45
- this.runToward(this.upperBound);
46
- }
47
- reverse() {
48
- this.reversing = !0, this.runToward(this.lowerBound);
49
- }
50
- pause() {
51
- var e;
52
- this.running && (this.captureLiveState(), (e = this.waapi) == null || e.pause(), this.running = !1, this.paused = !0);
53
- }
54
- complete() {
55
- var e;
56
- this.clearWaapi(), this.running = !1, this.paused = !1, this.currentValue = this.upperBound, this.currentVelocity = 0, this.applyStyleAt(this.currentValue), this.settled = !0, (e = this.onComplete) == null || e.call(this);
57
- }
58
- get isAnimating() {
59
- return this.running;
60
- }
61
- get isPaused() {
62
- return this.paused;
63
- }
64
- get isComplete() {
65
- return this.settled;
66
- }
67
- get isReversing() {
68
- return this.reversing;
69
- }
70
- get playbackRate() {
71
- return super.playbackRate;
72
- }
73
- set playbackRate(e) {
74
- super.playbackRate = e, this.waapi && (this.waapi.playbackRate = e);
75
- }
76
- getPose() {
77
- return this.running && this.captureLiveState(), [
78
- {
79
- element: this.element,
80
- value: this.currentValue,
81
- velocity: this.currentVelocity
82
- }
83
- ];
84
- }
85
- getTimeline() {
86
- const e = this.frames.map((t) => {
87
- const i = t.position, n = this.lowerBound + this.upperBound - i;
88
- return {
89
- time: t.time,
90
- value: t.position,
91
- velocity: t.velocity,
92
- style: this.styleFn(i, n)
93
- };
94
- });
95
- return [{ element: this.element, frames: e }];
96
- }
97
- matchInto(e) {
98
- const t = e.find((i) => i.element === this.element);
99
- t && (this.currentValue = t.value, this.currentVelocity = t.velocity);
100
- }
101
- /* ───────────────────────────────────────────────────────── private */
102
- runToward(e) {
103
- var h;
104
- if (this.running && this.captureLiveState(), this.clearWaapi(), this.running = !1, this.paused = !1, this.settled = !1, this.frames = g(
105
- this.integrator,
106
- this.currentValue,
107
- e,
108
- this.currentVelocity
109
- ), this.frames.length === 0) {
110
- this.currentValue = e, this.currentVelocity = 0, this.applyStyleAt(e), this.settled = !0, (h = this.onComplete) == null || h.call(this);
111
- return;
112
- }
113
- const t = this.frames.map((o) => {
114
- const u = o.position, m = this.lowerBound + this.upperBound - u;
115
- return this.styleFn(u, m);
116
- }), i = t[0];
117
- if (i)
118
- for (const o of Object.keys(i))
119
- this.element.style[o] = "";
120
- const n = this.frames[this.frames.length - 1], a = n.time;
121
- this.waapi = this.element.animate(t, {
122
- duration: a,
123
- fill: "forwards",
124
- easing: "linear",
125
- composite: "replace"
126
- }), this.waapi.playbackRate = this.playbackRate, this.startTime = performance.now(), this.running = !0, this.waapi.onfinish = () => {
127
- var o;
128
- this.running && (this.running = !1, this.settled = !0, this.currentValue = n.position, this.currentVelocity = 0, (o = this.onComplete) == null || o.call(this));
129
- };
130
- }
131
- clearWaapi() {
132
- var e;
133
- (e = this.waapi) == null || e.cancel(), this.waapi = null;
134
- }
135
- captureLiveState() {
136
- if (this.frames.length === 0) return;
137
- const e = performance.now() - this.startTime, { position: t, velocity: i } = v(this.frames, e);
138
- this.currentValue = t, this.currentVelocity = i;
139
- }
140
- applyStyleAt(e) {
141
- const t = this.lowerBound + this.upperBound - e, i = this.styleFn(e, t);
142
- for (const [n, a] of Object.entries(i))
143
- this.element.style[n] = typeof a == "number" ? String(a) : a;
144
- }
145
- }
146
- function g(r, l, e, t) {
147
- if (l === e && t === 0) return [];
148
- const i = 600;
149
- let n = { position: l, velocity: t }, a = 0;
150
- const h = [];
151
- for (let o = 0; o < i; o++) {
152
- const u = o * c;
153
- if (h.push({ time: u, position: n.position, velocity: n.velocity }), n = r.step(n, e, c / 1e3), r.isSettled(n, e)) {
154
- if (a += c / 1e3, a >= y) {
155
- h.push({
156
- time: (o + 1) * c,
157
- position: e,
158
- velocity: 0
159
- });
160
- break;
161
- }
162
- } else
163
- a = 0;
164
- }
165
- return h;
166
- }
167
- function v(r, l) {
168
- if (r.length === 0) return { position: 0, velocity: 0 };
169
- const e = r[0], t = r[r.length - 1];
170
- if (l <= 0)
171
- return { position: e.position, velocity: e.velocity };
172
- if (l >= t.time)
173
- return { position: t.position, velocity: t.velocity };
174
- let i = 0, n = r.length - 1;
175
- for (; i < n - 1; ) {
176
- const u = i + n >> 1;
177
- r[u].time <= l ? i = u : n = u;
178
- }
179
- const a = r[i], h = r[n], o = (l - a.time) / (h.time - a.time);
180
- return {
181
- position: a.position + (h.position - a.position) * o,
182
- velocity: a.velocity + (h.velocity - a.velocity) * o
183
- };
184
- }
185
- class k extends p {
186
- constructor(e, t = {}) {
187
- super();
188
- s(this, "children");
189
- s(this, "mode");
190
- s(this, "pendingComplete", 0);
191
- s(this, "running", !1);
192
- this.children = e, this.mode = t.mode ?? "parallel";
193
- }
194
- play() {
195
- this.running && this.pause(), this.running = !0, this.mode === "parallel" ? this.startParallel("play") : this.startSequence("play", 0);
196
- }
197
- reverse() {
198
- this.running && this.pause(), this.running = !0, this.mode === "parallel" ? this.startParallel("reverse") : this.startSequence("reverse", 0);
199
- }
200
- pause() {
201
- this.running = !1;
202
- for (const e of this.children) e.pause();
203
- }
204
- complete() {
205
- var e;
206
- this.running = !1;
207
- for (const t of this.children) t.complete();
208
- (e = this.onComplete) == null || e.call(this);
209
- }
210
- getPose() {
211
- return this.children.flatMap((e) => e.getPose());
212
- }
213
- getTimeline() {
214
- return this.children.flatMap((e) => e.getTimeline());
215
- }
216
- matchInto(e) {
217
- }
218
- get isAnimating() {
219
- return this.children.some((e) => e.isAnimating);
220
- }
221
- get isPaused() {
222
- return this.children.some((e) => e.isPaused) && this.children.every((e) => e.isPaused || e.isComplete);
223
- }
224
- get isComplete() {
225
- return this.children.every((e) => e.isComplete);
226
- }
227
- get isReversing() {
228
- return this.children.some((e) => e.isReversing);
229
- }
230
- get playbackRate() {
231
- return super.playbackRate;
232
- }
233
- set playbackRate(e) {
234
- super.playbackRate = e;
235
- for (const t of this.children) t.playbackRate = e;
236
- }
237
- /* ───────────────────────────────────────────────────────── private */
238
- startParallel(e) {
239
- if (this.pendingComplete = this.children.length, this.pendingComplete === 0) {
240
- this.handleFinished();
241
- return;
242
- }
243
- for (const t of this.children) {
244
- const i = t.onComplete;
245
- t.onComplete = () => {
246
- i == null || i(), this.handleChildComplete();
247
- }, t[e]();
248
- }
249
- }
250
- startSequence(e, t) {
251
- if (!this.running) return;
252
- if (t >= this.children.length) {
253
- this.handleFinished();
254
- return;
255
- }
256
- const i = this.children[t], n = i.onComplete;
257
- i.onComplete = () => {
258
- n == null || n(), this.startSequence(e, t + 1);
259
- }, i[e]();
260
- }
261
- handleChildComplete() {
262
- this.pendingComplete--, this.pendingComplete <= 0 && this.handleFinished();
263
- }
264
- handleFinished() {
265
- var e;
266
- this.running = !1, (e = this.onComplete) == null || e.call(this);
267
- }
268
- }
269
- export {
270
- p as A,
271
- k as M,
272
- R as P,
273
- y as S,
274
- C as V,
275
- b as W
276
- };