@ssgoi/core 0.0.1

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 (74) hide show
  1. package/README.md +34 -0
  2. package/dist/animator.d.ts +41 -0
  3. package/dist/animator.d.ts.map +1 -0
  4. package/dist/create-ssgoi-transition-context.d.ts +15 -0
  5. package/dist/create-ssgoi-transition-context.d.ts.map +1 -0
  6. package/dist/create-transition-callback.d.ts +36 -0
  7. package/dist/create-transition-callback.d.ts.map +1 -0
  8. package/dist/index.d.ts +4 -0
  9. package/dist/index.d.ts.map +1 -0
  10. package/dist/ssgoi.cjs +1 -0
  11. package/dist/ssgoi.js +1 -0
  12. package/dist/ssgoi2.cjs +1 -0
  13. package/dist/ssgoi2.js +305 -0
  14. package/dist/ssgoi3.cjs +1 -0
  15. package/dist/ssgoi3.js +173 -0
  16. package/dist/ssgoi4.cjs +1 -0
  17. package/dist/ssgoi4.js +764 -0
  18. package/dist/transition.d.ts +16 -0
  19. package/dist/transition.d.ts.map +1 -0
  20. package/dist/transitions/blur.d.ts +27 -0
  21. package/dist/transitions/blur.d.ts.map +1 -0
  22. package/dist/transitions/bounce.d.ts +27 -0
  23. package/dist/transitions/bounce.d.ts.map +1 -0
  24. package/dist/transitions/fade.d.ts +26 -0
  25. package/dist/transitions/fade.d.ts.map +1 -0
  26. package/dist/transitions/index.d.ts +8 -0
  27. package/dist/transitions/index.d.ts.map +1 -0
  28. package/dist/transitions/none.d.ts +24 -0
  29. package/dist/transitions/none.d.ts.map +1 -0
  30. package/dist/transitions/rotate.d.ts +28 -0
  31. package/dist/transitions/rotate.d.ts.map +1 -0
  32. package/dist/transitions/scale.d.ts +27 -0
  33. package/dist/transitions/scale.d.ts.map +1 -0
  34. package/dist/transitions/slide.d.ts +27 -0
  35. package/dist/transitions/slide.d.ts.map +1 -0
  36. package/dist/transitions.d.ts +2 -0
  37. package/dist/types.d.ts +38 -0
  38. package/dist/types.d.ts.map +1 -0
  39. package/dist/utils-BSgyev81.cjs +1 -0
  40. package/dist/utils-DR41YsAh.js +16 -0
  41. package/dist/utils.d.ts +11 -0
  42. package/dist/utils.d.ts.map +1 -0
  43. package/dist/view-transitions/fade.d.ts +7 -0
  44. package/dist/view-transitions/fade.d.ts.map +1 -0
  45. package/dist/view-transitions/hero.d.ts +8 -0
  46. package/dist/view-transitions/hero.d.ts.map +1 -0
  47. package/dist/view-transitions/index.d.ts +5 -0
  48. package/dist/view-transitions/index.d.ts.map +1 -0
  49. package/dist/view-transitions/pinterest.d.ts +8 -0
  50. package/dist/view-transitions/pinterest.d.ts.map +1 -0
  51. package/dist/view-transitions/ripple.d.ts +7 -0
  52. package/dist/view-transitions/ripple.d.ts.map +1 -0
  53. package/dist/view-transitions.d.ts +2 -0
  54. package/package.json +58 -0
  55. package/src/lib/animator.ts +172 -0
  56. package/src/lib/create-ssgoi-transition-context.ts +265 -0
  57. package/src/lib/create-transition-callback.ts +246 -0
  58. package/src/lib/index.ts +3 -0
  59. package/src/lib/transition.ts +76 -0
  60. package/src/lib/transitions/blur.ts +55 -0
  61. package/src/lib/transitions/bounce.ts +61 -0
  62. package/src/lib/transitions/fade.ts +33 -0
  63. package/src/lib/transitions/index.ts +7 -0
  64. package/src/lib/transitions/none.ts +27 -0
  65. package/src/lib/transitions/rotate.ts +57 -0
  66. package/src/lib/transitions/scale.ts +34 -0
  67. package/src/lib/transitions/slide.ts +53 -0
  68. package/src/lib/types.ts +60 -0
  69. package/src/lib/utils.ts +39 -0
  70. package/src/lib/view-transitions/fade.ts +29 -0
  71. package/src/lib/view-transitions/hero.ts +179 -0
  72. package/src/lib/view-transitions/index.ts +4 -0
  73. package/src/lib/view-transitions/pinterest.ts +403 -0
  74. package/src/lib/view-transitions/ripple.ts +45 -0
package/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # Ssgoi Core
2
+
3
+ TypeScript vanilla library for smooth page transitions.
4
+
5
+ ## Development
6
+
7
+ ```bash
8
+ # Install dependencies
9
+ pnpm install
10
+
11
+ # Start dev server
12
+ pnpm dev
13
+
14
+ # Build the library
15
+ pnpm build
16
+
17
+ # Preview the build
18
+ pnpm preview
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ ```typescript
24
+ import { createTransition } from '@ssgoi/core'
25
+
26
+ createTransition({
27
+ from: element1,
28
+ to: element2,
29
+ options: {
30
+ duration: 1000,
31
+ easing: 'ease-in-out'
32
+ }
33
+ })
34
+ ```
@@ -0,0 +1,41 @@
1
+ import { SpringConfig } from './types';
2
+ export interface AnimationOptions {
3
+ from: number;
4
+ to: number;
5
+ spring: SpringConfig;
6
+ onUpdate: (value: number) => void;
7
+ onComplete: () => void;
8
+ onStart?: () => void;
9
+ }
10
+ /**
11
+ * New Animator implementation using Popmotion
12
+ * Provides spring-based animations with fine control
13
+ */
14
+ export declare class Animator {
15
+ private options;
16
+ private currentValue;
17
+ private velocity;
18
+ private isAnimating;
19
+ private controls;
20
+ constructor(options: Partial<AnimationOptions>);
21
+ private animate;
22
+ forward(): void;
23
+ backward(): void;
24
+ reverse(): void;
25
+ stop(): void;
26
+ getVelocity(): number;
27
+ getCurrentValue(): number;
28
+ getIsAnimating(): boolean;
29
+ getCurrentState(): {
30
+ position: number;
31
+ velocity: number;
32
+ };
33
+ setVelocity(velocity: number): void;
34
+ setValue(value: number): void;
35
+ updateOptions(newOptions: Partial<AnimationOptions>): void;
36
+ static fromState(state: {
37
+ position: number;
38
+ velocity: number;
39
+ }, newOptions: Partial<AnimationOptions>): Animator;
40
+ }
41
+ //# sourceMappingURL=animator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"animator.d.ts","sourceRoot":"","sources":["../src/lib/animator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,YAAY,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED;;;GAGG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,OAAO,CAAmB;IAClC,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAa;IAC7B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,QAAQ,CAAqC;gBAEzC,OAAO,EAAE,OAAO,CAAC,gBAAgB,CAAC;IAY9C,OAAO,CAAC,OAAO,CA+Cb;IAGF,OAAO,IAAI,IAAI;IAKf,QAAQ,IAAI,IAAI;IAKhB,OAAO,IAAI,IAAI;IAef,IAAI,IAAI,IAAI;IAUZ,WAAW,IAAI,MAAM;IAIrB,eAAe,IAAI,MAAM;IAIzB,cAAc,IAAI,OAAO;IAIzB,eAAe,IAAI;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE;IAQzD,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAInC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK7B,aAAa,CAAC,UAAU,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAAG,IAAI;IAY1D,MAAM,CAAC,SAAS,CACd,KAAK,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,EAC7C,UAAU,EAAE,OAAO,CAAC,gBAAgB,CAAC,GACpC,QAAQ;CAMZ"}
@@ -0,0 +1,15 @@
1
+ import { SsgoiConfig, SsgoiContext } from './types';
2
+ /**
3
+ * Creates a transition configuration
4
+ *
5
+ * @example
6
+ * const config = createSggoiTransitionConfig({
7
+ * transitions: [
8
+ * { from: '/home', to: '/about', transition: fade() },
9
+ * { from: '/products', to: '/products/*', transition: slide() }
10
+ * ],
11
+ * defaultTransition: fade()
12
+ * });
13
+ */
14
+ export declare function createSggoiTransitionContext(options: SsgoiConfig): SsgoiContext;
15
+ //# sourceMappingURL=create-ssgoi-transition-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-ssgoi-transition-context.d.ts","sourceRoot":"","sources":["../src/lib/create-ssgoi-transition-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EAGb,MAAM,SAAS,CAAC;AA0CjB;;;;;;;;;;;GAWG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,WAAW,GACnB,YAAY,CAoJd"}
@@ -0,0 +1,36 @@
1
+ import { Transition, TransitionCallback } from './types';
2
+ /**
3
+ * Creates a transition callback that can be used with framework-specific implementations
4
+ * This is the core logic that frameworks can wrap with their own APIs
5
+ *
6
+ * UX Animation Behavior - 4 Main Scenarios:
7
+ *
8
+ * 1. No animation running + IN trigger:
9
+ * - Start entrance animation (0 → 1)
10
+ * - Return cleanup function for exit
11
+ *
12
+ * 2. No animation running + OUT trigger:
13
+ * - Clone element, start exit animation (1 → 0)
14
+ * - Remove clone when complete
15
+ *
16
+ * 3. IN animation running + OUT trigger:
17
+ * - Stop current IN animation (DOM is disappearing)
18
+ * - Clone element for exit animation
19
+ * - Create REVERSED IN animation (not OUT animation) with current state
20
+ * - This gives natural backward motion instead of jumping to OUT definition
21
+ *
22
+ * 4. OUT animation running + IN trigger:
23
+ * - Stop current OUT animation (cleanup any cloned elements)
24
+ * - Create REVERSED OUT animation (not IN animation) with current state
25
+ * - This gives natural backward motion instead of jumping to IN definition
26
+ * - Switch to entrance mode
27
+ *
28
+ * Closure Structure:
29
+ * - Outer function: Returns entrance callback
30
+ * - Inner function (entrance callback): Returns cleanup callback (exit)
31
+ * - Cleanup callback: Handles exit transitions
32
+ */
33
+ export declare function createTransitionCallback(getTransition: () => Transition, options?: {
34
+ onCleanupEnd?: () => void;
35
+ }): TransitionCallback;
36
+ //# sourceMappingURL=create-transition-callback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-transition-callback.d.ts","sourceRoot":"","sources":["../src/lib/create-transition-callback.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,wBAAwB,CACtC,aAAa,EAAE,MAAM,UAAU,EAC/B,OAAO,CAAC,EAAE;IACR,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;CAC3B,GACA,kBAAkB,CA+MpB"}
@@ -0,0 +1,4 @@
1
+ export * from './types';
2
+ export * from './transition';
3
+ export * from './create-ssgoi-transition-context';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,mCAAmC,CAAC"}
package/dist/ssgoi.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";
package/dist/ssgoi.js ADDED
@@ -0,0 +1 @@
1
+
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("./utils-BSgyev81.cjs"),C=(t={})=>{var e,i;const n={stiffness:((e=t.spring)==null?void 0:e.stiffness)??300,damping:((i=t.spring)==null?void 0:i.damping)??30};return{in:s=>({spring:n,tick:l=>{s.style.opacity=l.toString()}}),out:s=>({spring:n,tick:l=>{s.style.opacity=l.toString()},prepare:k.prepareOutgoing})}};function E(t,n){return t.querySelector(`[data-hero-key="${n}"]`)}function A(t,n){const e=t.getBoundingClientRect(),i=n.getBoundingClientRect();return new DOMRect(i.left-e.left,i.top-e.top,i.width,i.height)}const D=(t={})=>{var l,r;const n={stiffness:((l=t.spring)==null?void 0:l.stiffness)??300,damping:((r=t.spring)==null?void 0:r.damping)??30},e=t.timeout??300;let i=null,s=null;return{in:async(c,o)=>{const h=c,g=Array.from(h.querySelectorAll("[data-hero-key]"));if(g.length===0)return{spring:n,tick:()=>{}};if(!await new Promise(a=>{i?a(!0):(s=a,setTimeout(()=>{s=null,a(!1)},e))})||!i)return i=null,{spring:n,tick:()=>{}};const p=g.map(a=>{const f=a.getAttribute("data-hero-key");if(!f)return null;const u=E(i,f);if(!u)return null;const d=a,$=A(i,u),w=A(h,d),x=$.left-w.left-o.scrollOffset.x,M=$.top-w.top-o.scrollOffset.y,q=$.width/w.width,O=$.height/w.height,T=d.style.transform,P=d.style.position,b=d.style.transformOrigin;return{toEl:d,dx:x,dy:M,dw:q,dh:O,originalTransform:T,originalPosition:P,originalTransformOrigin:b}}).filter(Boolean);return i=null,p.length===0?{spring:n,tick:()=>{}}:{spring:n,prepare:()=>{p.forEach(({toEl:a})=>{a.style.position="relative",a.style.transformOrigin="top left"})},tick:a=>{p.forEach(({toEl:f,dx:u,dy:d,dw:$,dh:w})=>{f.style.transform=`translate(${(1-a)*u}px,${(1-a)*d}px) scale(${a+(1-a)*$}, ${a+(1-a)*w})`})},onEnd:()=>{p.forEach(({toEl:a,originalTransform:f,originalPosition:u,originalTransformOrigin:d})=>{a.style.transform=f,a.style.position=u,a.style.transformOrigin=d})}}},out:async c=>({onStart:()=>{i=c,s&&(s(!0),s=null)},prepare:o=>{k.prepareOutgoing(o),o.style.opacity="0"}})}};function S(t,n){const e=t.getBoundingClientRect(),i=n.getBoundingClientRect();return new DOMRect(i.left-e.left,i.top-e.top,i.width,i.height)}function H({detailRect:t,galleryRect:n,pageRect:e,scrollOffset:i},s){const l=n.left-t.left+(n.width-t.width)/2-i.x,r=n.top-t.top+(n.height-t.height)/2-i.y,c=n.width/t.width,o=n.height/t.height,h=Math.max(c,o),g=t.top/e.height*100,y=(e.width-(t.left+t.width))/e.width*100,p=(e.height-(t.top+t.height))/e.height*100,a=t.left/e.width*100;return s.style.transformOrigin=`${t.left+t.width/2}px ${t.top+t.height/2}px`,f=>{const u=1-f,d=g*u,$=y*u,w=p*u,x=a*u;s.style.clipPath=`inset(${d}% ${$}% ${w}% ${x}%)`,s.style.transform=`translate(${l*u}px, ${r*u}px) scale(${1+(h-1)*u})`}}function F({galleryRect:t,detailRect:n,scrollOffset:e},i){const s=n.left-t.left+(n.width-t.width)/2+e.x,l=n.top-t.top+(n.height-t.height)/2+e.y,r=n.width/t.width,c=n.height/t.height,o=Math.max(r,c);return h=>{i.style.transformOrigin=`${t.left+t.width/2}px ${t.top+t.height/2}px`;const g=1-h;i.style.transform=`translate(${s*g-e.x}px, ${l*g-e.y}px) scale(${1+(o-1)*g})`,i.style.opacity=`${1-g}`}}function I({galleryRect:t,detailRect:n,scrollOffset:e},i){const s=n.left-t.left+(n.width-t.width)/2-e.x,l=n.top-t.top+(n.height-t.height)/2-e.y,r=n.width/t.width,c=n.height/t.height,o=Math.max(r,c);return h=>{const g=1-h,y=h;i.style.transformOrigin=`${t.left+t.width/2}px ${t.top+t.height/2}px`,i.style.transform=`translate(${s*g}px, ${l*g}px) scale(${1+(o-1)*g})`,i.style.opacity=`${y}`}}function L({detailRect:t,galleryRect:n,pageRect:e,scrollOffset:i},s){const l=n.left-t.left+(n.width-t.width)/2+i.x,r=n.top-t.top+(n.height-t.height)/2+i.y,c=n.width/t.width,o=n.height/t.height,h=Math.min(c,o),g=t.top/e.height*100,y=(e.width-(t.left+t.width))/e.width*100,p=(e.height-(t.top+t.height))/e.height*100,a=t.left/e.width*100;return s.style.transformOrigin=`${t.left+t.width/2}px ${t.top+t.height/2}px`,f=>{const u=1-f,d=g*u,$=y*u,w=p*u,x=a*u;s.style.clipPath=`inset(${d}% ${$}% ${w}% ${x}%)`,s.style.transform=`translate(${l*u-i.x}px, ${r*u-i.y}px) scale(${1+(h-1)*u})`}}function X(t,n,e){const i=t.querySelector("[data-pinterest-detail-key]"),s=n.querySelector("[data-pinterest-detail-key]");if(t.querySelectorAll("[data-pinterest-detail-key]").length>1||n.querySelectorAll("[data-pinterest-detail-key]").length>1)return null;let l=null,r=null,c=!1;if(!i&&s){r=s;const y=r.getAttribute("data-pinterest-detail-key");if(!y)return null;l=t.querySelector(`[data-pinterest-gallery-key="${y}"]`),l&&(c=!0)}else if(i&&!s){r=i;const y=r.getAttribute("data-pinterest-detail-key");if(!y)return null;l=n.querySelector(`[data-pinterest-gallery-key="${y}"]`),l&&(c=!1)}if(!l||!r)return null;const o=S(c?t:n,l),h=S(c?n:t,r),g=n.getBoundingClientRect();return c?{inAnimation:H({detailRect:h,galleryRect:o,pageRect:g,scrollOffset:e},n),outAnimation:F({galleryRect:o,detailRect:h,scrollOffset:e},t)}:{inAnimation:I({galleryRect:o,detailRect:h,scrollOffset:e},n),outAnimation:L({detailRect:h,galleryRect:o,pageRect:g,scrollOffset:e},t)}}const Y=(t={})=>{var r,c;const n={stiffness:((r=t.spring)==null?void 0:r.stiffness)??50,damping:((c=t.spring)==null?void 0:c.damping)??10},e=t.timeout??300;let i=null,s=null,l=null;return{in:async(o,{scrollOffset:h})=>{const g=o;return!await new Promise(p=>{i?p(!0):(s=p,setTimeout(()=>{s=null,p(!1)},e))})||!i?(i=null,{spring:n,tick:()=>{}}):(l=X(i,g,h),l?(i=null,{spring:n,tick:p=>{l&&l.inAnimation(p)}}):{spring:n,tick:()=>{}})},out:async o=>({spring:n,onStart:()=>{i=o,s&&(s(!0),s=null)},prepare:h=>{k.prepareOutgoing(h),h.style.zIndex="-1"},tick:h=>{l&&l.outAnimation(h)}})}};function B(t){const n=t.getBoundingClientRect(),e=t.clientHeight,s=50*(window.innerHeight-n.top)/e;return Math.min(Math.max(s,0),100)}const m=(t={})=>{var e,i;const n={stiffness:((e=t.spring)==null?void 0:e.stiffness)??300,damping:((i=t.spring)==null?void 0:i.damping)??200};return{in:s=>{const l=B(s);return{spring:n,tick:r=>{s.style.clipPath=`circle(${r*100}% at 50% ${l}%)`}}},out:s=>{const l=B(s);return{spring:n,tick:r=>{s.style.clipPath=`circle(${r*100}% at 50% ${l}%)`,s.style.zIndex="100"},prepare:k.prepareOutgoing}}}};exports.fade=C;exports.hero=D;exports.pinterest=Y;exports.ripple=m;
package/dist/ssgoi2.js ADDED
@@ -0,0 +1,305 @@
1
+ import { p as k } from "./utils-DR41YsAh.js";
2
+ const X = (t = {}) => {
3
+ var e, i;
4
+ const n = {
5
+ stiffness: ((e = t.spring) == null ? void 0 : e.stiffness) ?? 300,
6
+ damping: ((i = t.spring) == null ? void 0 : i.damping) ?? 30
7
+ };
8
+ return {
9
+ in: (s) => ({
10
+ spring: n,
11
+ tick: (l) => {
12
+ s.style.opacity = l.toString();
13
+ }
14
+ }),
15
+ out: (s) => ({
16
+ spring: n,
17
+ tick: (l) => {
18
+ s.style.opacity = l.toString();
19
+ },
20
+ prepare: k
21
+ })
22
+ };
23
+ };
24
+ function D(t, n) {
25
+ return t.querySelector(`[data-hero-key="${n}"]`);
26
+ }
27
+ function A(t, n) {
28
+ const e = t.getBoundingClientRect(), i = n.getBoundingClientRect();
29
+ return new DOMRect(
30
+ i.left - e.left,
31
+ i.top - e.top,
32
+ i.width,
33
+ i.height
34
+ );
35
+ }
36
+ const Y = (t = {}) => {
37
+ var l, r;
38
+ const n = {
39
+ stiffness: ((l = t.spring) == null ? void 0 : l.stiffness) ?? 300,
40
+ damping: ((r = t.spring) == null ? void 0 : r.damping) ?? 30
41
+ }, e = t.timeout ?? 300;
42
+ let i = null, s = null;
43
+ return {
44
+ in: async (c, o) => {
45
+ const h = c, g = Array.from(h.querySelectorAll("[data-hero-key]"));
46
+ if (g.length === 0)
47
+ return {
48
+ spring: n,
49
+ tick: () => {
50
+ }
51
+ // No hero elements, skip animation
52
+ };
53
+ if (!await new Promise((a) => {
54
+ i ? a(!0) : (s = a, setTimeout(() => {
55
+ s = null, a(!1);
56
+ }, e));
57
+ }) || !i)
58
+ return i = null, {
59
+ spring: n,
60
+ tick: () => {
61
+ }
62
+ // No fromNode, skip animation
63
+ };
64
+ const p = g.map((a) => {
65
+ const f = a.getAttribute("data-hero-key");
66
+ if (!f) return null;
67
+ const u = D(i, f);
68
+ if (!u) return null;
69
+ const d = a, $ = A(i, u), w = A(h, d), x = $.left - w.left - o.scrollOffset.x, M = $.top - w.top - o.scrollOffset.y, q = $.width / w.width, T = $.height / w.height, C = d.style.transform, E = d.style.position, P = d.style.transformOrigin;
70
+ return {
71
+ toEl: d,
72
+ dx: x,
73
+ dy: M,
74
+ dw: q,
75
+ dh: T,
76
+ originalTransform: C,
77
+ originalPosition: E,
78
+ originalTransformOrigin: P
79
+ };
80
+ }).filter(Boolean);
81
+ return i = null, p.length === 0 ? {
82
+ spring: n,
83
+ tick: () => {
84
+ }
85
+ // No matching hero elements
86
+ } : {
87
+ spring: n,
88
+ prepare: () => {
89
+ p.forEach(({ toEl: a }) => {
90
+ a.style.position = "relative", a.style.transformOrigin = "top left";
91
+ });
92
+ },
93
+ tick: (a) => {
94
+ p.forEach(({ toEl: f, dx: u, dy: d, dw: $, dh: w }) => {
95
+ f.style.transform = `translate(${(1 - a) * u}px,${(1 - a) * d}px) scale(${a + (1 - a) * $}, ${a + (1 - a) * w})`;
96
+ });
97
+ },
98
+ onEnd: () => {
99
+ p.forEach(
100
+ ({
101
+ toEl: a,
102
+ originalTransform: f,
103
+ originalPosition: u,
104
+ originalTransformOrigin: d
105
+ }) => {
106
+ a.style.transform = f, a.style.position = u, a.style.transformOrigin = d;
107
+ }
108
+ );
109
+ }
110
+ };
111
+ },
112
+ out: async (c) => ({
113
+ onStart: () => {
114
+ i = c, s && (s(!0), s = null);
115
+ },
116
+ prepare: (o) => {
117
+ k(o), o.style.opacity = "0";
118
+ }
119
+ })
120
+ };
121
+ };
122
+ function S(t, n) {
123
+ const e = t.getBoundingClientRect(), i = n.getBoundingClientRect();
124
+ return new DOMRect(
125
+ i.left - e.left,
126
+ i.top - e.top,
127
+ i.width,
128
+ i.height
129
+ );
130
+ }
131
+ function H({
132
+ detailRect: t,
133
+ galleryRect: n,
134
+ pageRect: e,
135
+ scrollOffset: i
136
+ }, s) {
137
+ const l = n.left - t.left + (n.width - t.width) / 2 - i.x, r = n.top - t.top + (n.height - t.height) / 2 - i.y, c = n.width / t.width, o = n.height / t.height, h = Math.max(c, o), g = t.top / e.height * 100, y = (e.width - (t.left + t.width)) / e.width * 100, p = (e.height - (t.top + t.height)) / e.height * 100, a = t.left / e.width * 100;
138
+ return s.style.transformOrigin = `${t.left + t.width / 2}px ${t.top + t.height / 2}px`, (f) => {
139
+ const u = 1 - f, d = g * u, $ = y * u, w = p * u, x = a * u;
140
+ s.style.clipPath = `inset(${d}% ${$}% ${w}% ${x}%)`, s.style.transform = `translate(${l * u}px, ${r * u}px) scale(${1 + (h - 1) * u})`;
141
+ };
142
+ }
143
+ function b({
144
+ galleryRect: t,
145
+ detailRect: n,
146
+ scrollOffset: e
147
+ }, i) {
148
+ const s = n.left - t.left + (n.width - t.width) / 2 + e.x, l = n.top - t.top + (n.height - t.height) / 2 + e.y, r = n.width / t.width, c = n.height / t.height, o = Math.max(r, c);
149
+ return (h) => {
150
+ i.style.transformOrigin = `${t.left + t.width / 2}px ${t.top + t.height / 2}px`;
151
+ const g = 1 - h;
152
+ i.style.transform = `translate(${s * g - e.x}px, ${l * g - e.y}px) scale(${1 + (o - 1) * g})`, i.style.opacity = `${1 - g}`;
153
+ };
154
+ }
155
+ function O({
156
+ galleryRect: t,
157
+ detailRect: n,
158
+ scrollOffset: e
159
+ }, i) {
160
+ const s = n.left - t.left + (n.width - t.width) / 2 - e.x, l = n.top - t.top + (n.height - t.height) / 2 - e.y, r = n.width / t.width, c = n.height / t.height, o = Math.max(r, c);
161
+ return (h) => {
162
+ const g = 1 - h, y = h;
163
+ i.style.transformOrigin = `${t.left + t.width / 2}px ${t.top + t.height / 2}px`, i.style.transform = `translate(${s * g}px, ${l * g}px) scale(${1 + (o - 1) * g})`, i.style.opacity = `${y}`;
164
+ };
165
+ }
166
+ function F({
167
+ detailRect: t,
168
+ galleryRect: n,
169
+ pageRect: e,
170
+ scrollOffset: i
171
+ }, s) {
172
+ const l = n.left - t.left + (n.width - t.width) / 2 + i.x, r = n.top - t.top + (n.height - t.height) / 2 + i.y, c = n.width / t.width, o = n.height / t.height, h = Math.min(c, o), g = t.top / e.height * 100, y = (e.width - (t.left + t.width)) / e.width * 100, p = (e.height - (t.top + t.height)) / e.height * 100, a = t.left / e.width * 100;
173
+ return s.style.transformOrigin = `${t.left + t.width / 2}px ${t.top + t.height / 2}px`, (f) => {
174
+ const u = 1 - f, d = g * u, $ = y * u, w = p * u, x = a * u;
175
+ s.style.clipPath = `inset(${d}% ${$}% ${w}% ${x}%)`, s.style.transform = `translate(${l * u - i.x}px, ${r * u - i.y}px) scale(${1 + (h - 1) * u})`;
176
+ };
177
+ }
178
+ function I(t, n, e) {
179
+ const i = t.querySelector(
180
+ "[data-pinterest-detail-key]"
181
+ ), s = n.querySelector(
182
+ "[data-pinterest-detail-key]"
183
+ );
184
+ if (t.querySelectorAll("[data-pinterest-detail-key]").length > 1 || n.querySelectorAll("[data-pinterest-detail-key]").length > 1)
185
+ return null;
186
+ let l = null, r = null, c = !1;
187
+ if (!i && s) {
188
+ r = s;
189
+ const y = r.getAttribute("data-pinterest-detail-key");
190
+ if (!y) return null;
191
+ l = t.querySelector(
192
+ `[data-pinterest-gallery-key="${y}"]`
193
+ ), l && (c = !0);
194
+ } else if (i && !s) {
195
+ r = i;
196
+ const y = r.getAttribute("data-pinterest-detail-key");
197
+ if (!y) return null;
198
+ l = n.querySelector(
199
+ `[data-pinterest-gallery-key="${y}"]`
200
+ ), l && (c = !1);
201
+ }
202
+ if (!l || !r)
203
+ return null;
204
+ const o = S(c ? t : n, l), h = S(c ? n : t, r), g = n.getBoundingClientRect();
205
+ return c ? {
206
+ inAnimation: H(
207
+ { detailRect: h, galleryRect: o, pageRect: g, scrollOffset: e },
208
+ n
209
+ ),
210
+ outAnimation: b(
211
+ { galleryRect: o, detailRect: h, scrollOffset: e },
212
+ t
213
+ )
214
+ } : {
215
+ inAnimation: O(
216
+ { galleryRect: o, detailRect: h, scrollOffset: e },
217
+ n
218
+ ),
219
+ outAnimation: F(
220
+ { detailRect: h, galleryRect: o, pageRect: g, scrollOffset: e },
221
+ t
222
+ )
223
+ };
224
+ }
225
+ const m = (t = {}) => {
226
+ var r, c;
227
+ const n = {
228
+ stiffness: ((r = t.spring) == null ? void 0 : r.stiffness) ?? 50,
229
+ damping: ((c = t.spring) == null ? void 0 : c.damping) ?? 10
230
+ }, e = t.timeout ?? 300;
231
+ let i = null, s = null, l = null;
232
+ return {
233
+ in: async (o, { scrollOffset: h }) => {
234
+ const g = o;
235
+ return !await new Promise((p) => {
236
+ i ? p(!0) : (s = p, setTimeout(() => {
237
+ s = null, p(!1);
238
+ }, e));
239
+ }) || !i ? (i = null, {
240
+ spring: n,
241
+ tick: () => {
242
+ }
243
+ }) : (l = I(i, g, h), l ? (i = null, {
244
+ spring: n,
245
+ tick: (p) => {
246
+ l && l.inAnimation(p);
247
+ }
248
+ }) : {
249
+ spring: n,
250
+ tick: () => {
251
+ }
252
+ });
253
+ },
254
+ out: async (o) => ({
255
+ spring: n,
256
+ onStart: () => {
257
+ i = o, s && (s(!0), s = null);
258
+ },
259
+ prepare: (h) => {
260
+ k(h), h.style.zIndex = "-1";
261
+ },
262
+ tick: (h) => {
263
+ l && l.outAnimation(h);
264
+ }
265
+ })
266
+ };
267
+ };
268
+ function B(t) {
269
+ const n = t.getBoundingClientRect(), e = t.clientHeight, s = 50 * (window.innerHeight - n.top) / e;
270
+ return Math.min(Math.max(s, 0), 100);
271
+ }
272
+ const z = (t = {}) => {
273
+ var e, i;
274
+ const n = {
275
+ stiffness: ((e = t.spring) == null ? void 0 : e.stiffness) ?? 300,
276
+ damping: ((i = t.spring) == null ? void 0 : i.damping) ?? 200
277
+ };
278
+ return {
279
+ in: (s) => {
280
+ const l = B(s);
281
+ return {
282
+ spring: n,
283
+ tick: (r) => {
284
+ s.style.clipPath = `circle(${r * 100}% at 50% ${l}%)`;
285
+ }
286
+ };
287
+ },
288
+ out: (s) => {
289
+ const l = B(s);
290
+ return {
291
+ spring: n,
292
+ tick: (r) => {
293
+ s.style.clipPath = `circle(${r * 100}% at 50% ${l}%)`, s.style.zIndex = "100";
294
+ },
295
+ prepare: k
296
+ };
297
+ }
298
+ };
299
+ };
300
+ export {
301
+ X as fade,
302
+ Y as hero,
303
+ m as pinterest,
304
+ z as ripple
305
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=(r={})=>{const{from:i=0,to:c=1,spring:a={stiffness:300,damping:30}}=r;return{in:o=>({spring:a,tick:s=>{const t=i+(c-i)*s;o.style.opacity=t.toString()}}),out:o=>({spring:a,tick:s=>{const t=i+(c-i)*s;o.style.opacity=t.toString()}})}},u=(r={})=>{const{from:i=0,to:c=1,spring:a={stiffness:300,damping:30}}=r;return{in:o=>({spring:a,tick:s=>{const t=i+(c-i)*s;o.style.transform=`scale(${t})`}}),out:o=>({spring:a,tick:s=>{const t=i+(c-i)*s;o.style.transform=`scale(${t})`}})}},y=(r={})=>{const{direction:i="left",distance:c=100,fade:a=!0,spring:o={stiffness:400,damping:35}}=r,s=t=>{const n=(1-t)*c;switch(i){case"left":return`translateX(${-n}px)`;case"right":return`translateX(${n}px)`;case"up":return`translateY(${-n}px)`;case"down":return`translateY(${n}px)`}};return{in:t=>({spring:o,tick:n=>{t.style.transform=s(n),a&&(t.style.opacity=n.toString())}}),out:t=>({spring:o,tick:n=>{t.style.transform=s(n),a&&(t.style.opacity=n.toString())}})}},p=(r={})=>{const{degrees:i=360,clockwise:c=!0,scale:a=!1,fade:o=!1,spring:s={stiffness:500,damping:25}}=r,t=c?i:-i;return{in:n=>({spring:s,tick:e=>{const f=[`rotate(${e*t}deg)`];a&&f.push(`scale(${e})`),n.style.transform=f.join(" "),o&&(n.style.opacity=e.toString())}}),out:n=>({spring:s,tick:e=>{const f=[`rotate(${e*t}deg)`];a&&f.push(`scale(${e})`),n.style.transform=f.join(" "),o&&(n.style.opacity=e.toString())}})}},d=(r={})=>{const{height:i=20,scale:c=!0,fade:a=!1,spring:o={stiffness:800,damping:15}}=r;return{in:s=>({spring:o,tick:t=>{const n=[],e=Math.sin(t*Math.PI)*i*(1-t);n.push(`translateY(${-e}px)`),c&&n.push(`scale(${.8+t*.2})`),s.style.transform=n.join(" "),a&&(s.style.opacity=t.toString())}}),out:s=>({spring:o,tick:t=>{const n=[],e=Math.sin(t*Math.PI)*i*(1-t);n.push(`translateY(${-e}px)`),c&&n.push(`scale(${.8+t*.2})`),s.style.transform=n.join(" "),a&&(s.style.opacity=t.toString())}})}},g=(r={})=>{const{amount:i=10,scale:c=!1,fade:a=!0,spring:o={stiffness:300,damping:30}}=r;return{in:s=>({spring:o,tick:t=>{const e=[`blur(${(1-t)*i}px)`];s.style.filter=e.join(" "),c&&(s.style.transform=`scale(${.8+t*.2})`),a&&(s.style.opacity=t.toString())}}),out:s=>({spring:o,tick:t=>{const e=[`blur(${(1-t)*i}px)`];s.style.filter=e.join(" "),c&&(s.style.transform=`scale(${.8+t*.2})`),a&&(s.style.opacity=t.toString())}})}},m=(r={})=>{const{spring:i={stiffness:1e3,damping:100}}=r;return{in:c=>({spring:i,tick:a=>{}}),out:c=>({spring:i,tick:a=>{}})}};exports.blur=g;exports.bounce=d;exports.fade=l;exports.none=m;exports.rotate=p;exports.scale=u;exports.slide=y;
package/dist/ssgoi3.js ADDED
@@ -0,0 +1,173 @@
1
+ const l = (r = {}) => {
2
+ const {
3
+ from: i = 0,
4
+ to: c = 1,
5
+ spring: a = { stiffness: 300, damping: 30 }
6
+ } = r;
7
+ return {
8
+ in: (o) => ({
9
+ spring: a,
10
+ tick: (s) => {
11
+ const t = i + (c - i) * s;
12
+ o.style.opacity = t.toString();
13
+ }
14
+ }),
15
+ out: (o) => ({
16
+ spring: a,
17
+ tick: (s) => {
18
+ const t = i + (c - i) * s;
19
+ o.style.opacity = t.toString();
20
+ }
21
+ })
22
+ };
23
+ }, u = (r = {}) => {
24
+ const {
25
+ from: i = 0,
26
+ to: c = 1,
27
+ spring: a = { stiffness: 300, damping: 30 }
28
+ } = r;
29
+ return {
30
+ in: (o) => ({
31
+ spring: a,
32
+ tick: (s) => {
33
+ const t = i + (c - i) * s;
34
+ o.style.transform = `scale(${t})`;
35
+ }
36
+ }),
37
+ out: (o) => ({
38
+ spring: a,
39
+ tick: (s) => {
40
+ const t = i + (c - i) * s;
41
+ o.style.transform = `scale(${t})`;
42
+ }
43
+ })
44
+ };
45
+ }, y = (r = {}) => {
46
+ const {
47
+ direction: i = "left",
48
+ distance: c = 100,
49
+ fade: a = !0,
50
+ spring: o = { stiffness: 400, damping: 35 }
51
+ } = r, s = (t) => {
52
+ const n = (1 - t) * c;
53
+ switch (i) {
54
+ case "left":
55
+ return `translateX(${-n}px)`;
56
+ case "right":
57
+ return `translateX(${n}px)`;
58
+ case "up":
59
+ return `translateY(${-n}px)`;
60
+ case "down":
61
+ return `translateY(${n}px)`;
62
+ }
63
+ };
64
+ return {
65
+ in: (t) => ({
66
+ spring: o,
67
+ tick: (n) => {
68
+ t.style.transform = s(n), a && (t.style.opacity = n.toString());
69
+ }
70
+ }),
71
+ out: (t) => ({
72
+ spring: o,
73
+ tick: (n) => {
74
+ t.style.transform = s(n), a && (t.style.opacity = n.toString());
75
+ }
76
+ })
77
+ };
78
+ }, p = (r = {}) => {
79
+ const {
80
+ degrees: i = 360,
81
+ clockwise: c = !0,
82
+ scale: a = !1,
83
+ fade: o = !1,
84
+ spring: s = { stiffness: 500, damping: 25 }
85
+ } = r, t = c ? i : -i;
86
+ return {
87
+ in: (n) => ({
88
+ spring: s,
89
+ tick: (e) => {
90
+ const f = [`rotate(${e * t}deg)`];
91
+ a && f.push(`scale(${e})`), n.style.transform = f.join(" "), o && (n.style.opacity = e.toString());
92
+ }
93
+ }),
94
+ out: (n) => ({
95
+ spring: s,
96
+ tick: (e) => {
97
+ const f = [`rotate(${e * t}deg)`];
98
+ a && f.push(`scale(${e})`), n.style.transform = f.join(" "), o && (n.style.opacity = e.toString());
99
+ }
100
+ })
101
+ };
102
+ }, d = (r = {}) => {
103
+ const {
104
+ height: i = 20,
105
+ scale: c = !0,
106
+ fade: a = !1,
107
+ spring: o = { stiffness: 800, damping: 15 }
108
+ } = r;
109
+ return {
110
+ in: (s) => ({
111
+ spring: o,
112
+ tick: (t) => {
113
+ const n = [], e = Math.sin(t * Math.PI) * i * (1 - t);
114
+ n.push(`translateY(${-e}px)`), c && n.push(`scale(${0.8 + t * 0.2})`), s.style.transform = n.join(" "), a && (s.style.opacity = t.toString());
115
+ }
116
+ }),
117
+ out: (s) => ({
118
+ spring: o,
119
+ tick: (t) => {
120
+ const n = [], e = Math.sin(t * Math.PI) * i * (1 - t);
121
+ n.push(`translateY(${-e}px)`), c && n.push(`scale(${0.8 + t * 0.2})`), s.style.transform = n.join(" "), a && (s.style.opacity = t.toString());
122
+ }
123
+ })
124
+ };
125
+ }, $ = (r = {}) => {
126
+ const {
127
+ amount: i = 10,
128
+ scale: c = !1,
129
+ fade: a = !0,
130
+ spring: o = { stiffness: 300, damping: 30 }
131
+ } = r;
132
+ return {
133
+ in: (s) => ({
134
+ spring: o,
135
+ tick: (t) => {
136
+ const e = [`blur(${(1 - t) * i}px)`];
137
+ s.style.filter = e.join(" "), c && (s.style.transform = `scale(${0.8 + t * 0.2})`), a && (s.style.opacity = t.toString());
138
+ }
139
+ }),
140
+ out: (s) => ({
141
+ spring: o,
142
+ tick: (t) => {
143
+ const e = [`blur(${(1 - t) * i}px)`];
144
+ s.style.filter = e.join(" "), c && (s.style.transform = `scale(${0.8 + t * 0.2})`), a && (s.style.opacity = t.toString());
145
+ }
146
+ })
147
+ };
148
+ }, m = (r = {}) => {
149
+ const {
150
+ spring: i = { stiffness: 1e3, damping: 100 }
151
+ } = r;
152
+ return {
153
+ in: (c) => ({
154
+ spring: i,
155
+ tick: (a) => {
156
+ }
157
+ }),
158
+ out: (c) => ({
159
+ spring: i,
160
+ tick: (a) => {
161
+ }
162
+ })
163
+ };
164
+ };
165
+ export {
166
+ $ as blur,
167
+ d as bounce,
168
+ l as fade,
169
+ m as none,
170
+ p as rotate,
171
+ u as scale,
172
+ y as slide
173
+ };