@ssgoi/core 0.0.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +252 -23
- package/dist/animator.d.ts +28 -17
- package/dist/animator.d.ts.map +1 -1
- package/dist/create-transition-callback.d.ts +3 -32
- package/dist/create-transition-callback.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +310 -195
- package/dist/presets/index.cjs +1 -0
- package/dist/presets/index.d.ts +16 -0
- package/dist/presets/index.d.ts.map +1 -0
- package/dist/presets/index.js +35 -0
- package/dist/transition-strategy.d.ts +60 -0
- package/dist/transition-strategy.d.ts.map +1 -0
- package/dist/transition.d.ts +7 -3
- package/dist/transition.d.ts.map +1 -1
- package/dist/transitions/blur.d.ts +2 -1
- package/dist/transitions/blur.d.ts.map +1 -1
- package/dist/transitions/bounce.d.ts +2 -0
- package/dist/transitions/bounce.d.ts.map +1 -1
- package/dist/transitions/fly.d.ts +27 -0
- package/dist/transitions/fly.d.ts.map +1 -0
- package/dist/transitions/index.cjs +1 -1
- package/dist/transitions/index.d.ts +1 -0
- package/dist/transitions/index.d.ts.map +1 -1
- package/dist/transitions/index.js +175 -111
- package/dist/transitions/rotate.d.ts +3 -0
- package/dist/transitions/rotate.d.ts.map +1 -1
- package/dist/transitions/scale.d.ts +3 -3
- package/dist/transitions/scale.d.ts.map +1 -1
- package/dist/transitions/slide.d.ts +3 -1
- package/dist/transitions/slide.d.ts.map +1 -1
- package/dist/types.d.ts +8 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/view-transitions/index.cjs +1 -1
- package/dist/view-transitions/index.d.ts +1 -1
- package/dist/view-transitions/index.js +117 -126
- package/dist/view-transitions/scroll.d.ts +8 -0
- package/dist/view-transitions/scroll.d.ts.map +1 -0
- package/package.json +29 -8
package/dist/types.d.ts
CHANGED
|
@@ -3,17 +3,19 @@ export type SpringConfig = {
|
|
|
3
3
|
stiffness?: number;
|
|
4
4
|
damping?: number;
|
|
5
5
|
};
|
|
6
|
-
export type TransitionConfig = {
|
|
6
|
+
export type TransitionConfig<TAnimationValue = number> = {
|
|
7
7
|
spring?: SpringConfig;
|
|
8
|
-
|
|
8
|
+
from?: TAnimationValue;
|
|
9
|
+
to?: TAnimationValue;
|
|
10
|
+
tick?: (progress: TAnimationValue) => void;
|
|
9
11
|
prepare?: (element: HTMLElement) => void;
|
|
10
12
|
onStart?: () => void;
|
|
11
13
|
onEnd?: () => void;
|
|
12
14
|
};
|
|
13
|
-
export type GetTransitionConfig<TContext = undefined> = TContext extends undefined ? (node: HTMLElement) => TransitionConfig | Promise<TransitionConfig
|
|
14
|
-
export type Transition<TContext = undefined> = {
|
|
15
|
-
in?: GetTransitionConfig<TContext>;
|
|
16
|
-
out?: GetTransitionConfig<TContext>;
|
|
15
|
+
export type GetTransitionConfig<TContext = undefined, TAnimationValue = number> = TContext extends undefined ? (node: HTMLElement) => TransitionConfig<TAnimationValue> | Promise<TransitionConfig<TAnimationValue>> : (node: HTMLElement, context: TContext) => TransitionConfig<TAnimationValue> | Promise<TransitionConfig<TAnimationValue>>;
|
|
16
|
+
export type Transition<TContext = undefined, TAnimationValue = number> = {
|
|
17
|
+
in?: GetTransitionConfig<TContext, TAnimationValue>;
|
|
18
|
+
out?: GetTransitionConfig<TContext, TAnimationValue>;
|
|
17
19
|
};
|
|
18
20
|
export type TransitionCallback = (element: HTMLElement | null) => void | (() => void);
|
|
19
21
|
export type SggoiTransitionContext = {
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/lib/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,CAAC;AAE5C,MAAM,MAAM,YAAY,GAAG;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/lib/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,CAAC;AAE5C,MAAM,MAAM,YAAY,GAAG;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,gBAAgB,CAAC,eAAe,GAAG,MAAM,IAAI;IAEvD,MAAM,CAAC,EAAE,YAAY,CAAC;IAGtB,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB,EAAE,CAAC,EAAE,eAAe,CAAC;IAGrB,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,IAAI,CAAC;IAG3C,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,CAAC;IAGzC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IAGrB,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,mBAAmB,CAAC,QAAQ,GAAG,SAAS,EAAE,eAAe,GAAG,MAAM,IAC5E,QAAQ,SAAS,SAAS,GACtB,CAAC,IAAI,EAAE,WAAW,KAAK,gBAAgB,CAAC,eAAe,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC,GACrG,CACE,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE,QAAQ,KACd,gBAAgB,CAAC,eAAe,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC,CAAC;AAE1F,MAAM,MAAM,UAAU,CAAC,QAAQ,GAAG,SAAS,EAAE,eAAe,GAAG,MAAM,IAAI;IACvE,EAAE,CAAC,EAAE,mBAAmB,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;IACpD,GAAG,CAAC,EAAE,mBAAmB,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;CACtD,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,CAC/B,OAAO,EAAE,WAAW,GAAG,IAAI,KACxB,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;AAEzB,MAAM,MAAM,sBAAsB,GAAG;IACnC,YAAY,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,sBAAsB,CAAC,CAAC;AAEjE,MAAM,MAAM,WAAW,GAAG;IACxB,WAAW,EAAE;QACX,IAAI,EAAE,MAAM,CAAC;QACb,EAAE,EAAE,MAAM,CAAC;QACX,UAAU,EAAE,eAAe,CAAC;QAC5B,SAAS,CAAC,EAAE,OAAO,CAAC;KACrB,EAAE,CAAC;IACJ,iBAAiB,CAAC,EAAE,eAAe,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,CACzB,IAAI,EAAE,MAAM,KACT,UAAU,GAAG;IAAE,GAAG,EAAE,aAAa,CAAA;CAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("../utils-BSgyev81.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("../utils-BSgyev81.cjs"),E=(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 m(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 C=(t={})=>{var l,h;const n={stiffness:((l=t.spring)==null?void 0:l.stiffness)??300,damping:((h=t.spring)==null?void 0:h.damping)??30},e=t.timeout??300;let i=null,s=null;return{in:async(r,a)=>{const u=r,g=Array.from(u.querySelectorAll("[data-hero-key]"));if(g.length===0)return{spring:n,tick:()=>{}};if(!await new Promise(o=>{i?o(!0):(s=o,setTimeout(()=>{s=null,o(!1)},e))})||!i)return i=null,{spring:n,tick:()=>{}};const p=g.map(o=>{const $=o.getAttribute("data-hero-key");if(!$)return null;const c=m(i,$);if(!c)return null;const d=o,w=A(i,c),f=A(u,d),x=w.left-f.left-a.scrollOffset.x,B=w.top-f.top-a.scrollOffset.y,q=w.width/f.width,T=w.height/f.height,M=d.style.transform,O=d.style.position,Y=d.style.transformOrigin;return{toEl:d,dx:x,dy:B,dw:q,dh:T,originalTransform:M,originalPosition:O,originalTransformOrigin:Y}}).filter(Boolean);return i=null,p.length===0?{spring:n,tick:()=>{}}:{spring:n,prepare:()=>{p.forEach(({toEl:o})=>{o.style.position="relative",o.style.transformOrigin="top left"})},tick:o=>{p.forEach(({toEl:$,dx:c,dy:d,dw:w,dh:f})=>{$.style.transform=`translate(${(1-o)*c}px,${(1-o)*d}px) scale(${o+(1-o)*w}, ${o+(1-o)*f})`})},onEnd:()=>{p.forEach(({toEl:o,originalTransform:$,originalPosition:c,originalTransformOrigin:d})=>{o.style.transform=$,o.style.position=c,o.style.transformOrigin=d})}}},out:async r=>({onStart:()=>{i=r,s&&(s(!0),s=null)},prepare:a=>{k.prepareOutgoing(a),a.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 D({detailRect:t,galleryRect:n,pageRect:e,scrollOffset:i},s){const l=n.left-t.left+(n.width-t.width)/2-i.x,h=n.top-t.top+(n.height-t.height)/2-i.y,r=n.width/t.width,a=n.height/t.height,u=Math.max(r,a),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,o=t.left/e.width*100;return s.style.transformOrigin=`${t.left+t.width/2}px ${t.top+t.height/2}px`,$=>{const c=1-$,d=g*c,w=y*c,f=p*c,x=o*c;s.style.clipPath=`inset(${d}% ${w}% ${f}% ${x}%)`,s.style.transform=`translate(${l*c}px, ${h*c}px) scale(${1+(u-1)*c})`}}function P({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,h=n.width/t.width,r=n.height/t.height,a=Math.max(h,r);return u=>{i.style.transformOrigin=`${t.left+t.width/2}px ${t.top+t.height/2}px`;const g=1-u;i.style.transform=`translate(${s*g-e.x}px, ${l*g-e.y}px) scale(${1+(a-1)*g})`,i.style.opacity=`${1-g}`}}function b({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,h=n.width/t.width,r=n.height/t.height,a=Math.max(h,r);return u=>{const g=1-u,y=u;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+(a-1)*g})`,i.style.opacity=`${y}`}}function F({detailRect:t,galleryRect:n,pageRect:e,scrollOffset:i},s){const l=n.left-t.left+(n.width-t.width)/2+i.x,h=n.top-t.top+(n.height-t.height)/2+i.y,r=n.width/t.width,a=n.height/t.height,u=Math.min(r,a),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,o=t.left/e.width*100;return s.style.transformOrigin=`${t.left+t.width/2}px ${t.top+t.height/2}px`,$=>{const c=1-$,d=g*c,w=y*c,f=p*c,x=o*c;s.style.clipPath=`inset(${d}% ${w}% ${f}% ${x}%)`,s.style.transform=`translate(${l*c-i.x}px, ${h*c-i.y}px) scale(${1+(u-1)*c})`}}function L(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,h=null,r=!1;if(!i&&s){h=s;const y=h.getAttribute("data-pinterest-detail-key");if(!y)return null;l=t.querySelector(`[data-pinterest-gallery-key="${y}"]`),l&&(r=!0)}else if(i&&!s){h=i;const y=h.getAttribute("data-pinterest-detail-key");if(!y)return null;l=n.querySelector(`[data-pinterest-gallery-key="${y}"]`),l&&(r=!1)}if(!l||!h)return null;const a=S(r?t:n,l),u=S(r?n:t,h),g=n.getBoundingClientRect();return r?{inAnimation:D({detailRect:u,galleryRect:a,pageRect:g,scrollOffset:e},n),outAnimation:P({galleryRect:a,detailRect:u,scrollOffset:e},t)}:{inAnimation:b({galleryRect:a,detailRect:u,scrollOffset:e},n),outAnimation:F({detailRect:u,galleryRect:a,pageRect:g,scrollOffset:e},t)}}const X=(t={})=>{var h,r;const n={stiffness:((h=t.spring)==null?void 0:h.stiffness)??50,damping:((r=t.spring)==null?void 0:r.damping)??10},e=t.timeout??300;let i=null,s=null,l=null;return{in:async(a,{scrollOffset:u})=>{const g=a;return!await new Promise(p=>{i?p(!0):(s=p,setTimeout(()=>{s=null,p(!1)},e))})||!i?(i=null,{spring:n,tick:()=>{}}):(l=L(i,g,u),l?(i=null,{spring:n,tick:p=>{l&&l.inAnimation(p)}}):{spring:n,tick:()=>{}})},out:async a=>({spring:n,onStart:()=>{i=a,s&&(s(!0),s=null)},prepare:u=>{k.prepareOutgoing(u),u.style.zIndex="-1"},tick:u=>{l&&l.outAnimation(u)}})}},I=(t={})=>{var s,l;const n=t.direction??"up",e={stiffness:((s=t.spring)==null?void 0:s.stiffness)??300,damping:((l=t.spring)==null?void 0:l.damping)??30},i=n==="up";return{in:h=>({spring:e,tick:r=>{const a=i?(1-r)*100:(1-r)*-100;h.style.transform=`translateY(${a}%)`}}),out:h=>({spring:e,tick:r=>{const a=i?(1-r)*-100:(1-r)*100;h.style.transform=`translateY(${a}%)`},prepare:k.prepareOutgoing})}};exports.fade=E;exports.hero=C;exports.pinterest=X;exports.scroll=I;
|
|
@@ -21,7 +21,7 @@ const X = (t = {}) => {
|
|
|
21
21
|
})
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
|
-
function
|
|
24
|
+
function M(t, n) {
|
|
25
25
|
return t.querySelector(`[data-hero-key="${n}"]`);
|
|
26
26
|
}
|
|
27
27
|
function A(t, n) {
|
|
@@ -33,16 +33,16 @@ function A(t, n) {
|
|
|
33
33
|
i.height
|
|
34
34
|
);
|
|
35
35
|
}
|
|
36
|
-
const
|
|
37
|
-
var l,
|
|
36
|
+
const b = (t = {}) => {
|
|
37
|
+
var l, h;
|
|
38
38
|
const n = {
|
|
39
39
|
stiffness: ((l = t.spring) == null ? void 0 : l.stiffness) ?? 300,
|
|
40
|
-
damping: ((
|
|
40
|
+
damping: ((h = t.spring) == null ? void 0 : h.damping) ?? 30
|
|
41
41
|
}, e = t.timeout ?? 300;
|
|
42
42
|
let i = null, s = null;
|
|
43
43
|
return {
|
|
44
|
-
in: async (
|
|
45
|
-
const
|
|
44
|
+
in: async (a, r) => {
|
|
45
|
+
const u = a, g = Array.from(u.querySelectorAll("[data-hero-key]"));
|
|
46
46
|
if (g.length === 0)
|
|
47
47
|
return {
|
|
48
48
|
spring: n,
|
|
@@ -50,9 +50,9 @@ const Y = (t = {}) => {
|
|
|
50
50
|
}
|
|
51
51
|
// No hero elements, skip animation
|
|
52
52
|
};
|
|
53
|
-
if (!await new Promise((
|
|
54
|
-
i ?
|
|
55
|
-
s = null,
|
|
53
|
+
if (!await new Promise((o) => {
|
|
54
|
+
i ? o(!0) : (s = o, setTimeout(() => {
|
|
55
|
+
s = null, o(!1);
|
|
56
56
|
}, e));
|
|
57
57
|
}) || !i)
|
|
58
58
|
return i = null, {
|
|
@@ -61,24 +61,24 @@ const Y = (t = {}) => {
|
|
|
61
61
|
}
|
|
62
62
|
// No fromNode, skip animation
|
|
63
63
|
};
|
|
64
|
-
const
|
|
65
|
-
const
|
|
66
|
-
if (
|
|
67
|
-
const
|
|
68
|
-
if (!
|
|
69
|
-
const d =
|
|
64
|
+
const y = g.map((o) => {
|
|
65
|
+
const $ = o.getAttribute("data-hero-key");
|
|
66
|
+
if (!$) return null;
|
|
67
|
+
const c = M(i, $);
|
|
68
|
+
if (!c) return null;
|
|
69
|
+
const d = o, w = A(i, c), f = A(u, d), x = w.left - f.left - r.scrollOffset.x, B = w.top - f.top - r.scrollOffset.y, q = w.width / f.width, T = w.height / f.height, Y = d.style.transform, m = d.style.position, E = d.style.transformOrigin;
|
|
70
70
|
return {
|
|
71
71
|
toEl: d,
|
|
72
72
|
dx: x,
|
|
73
|
-
dy:
|
|
73
|
+
dy: B,
|
|
74
74
|
dw: q,
|
|
75
75
|
dh: T,
|
|
76
|
-
originalTransform:
|
|
77
|
-
originalPosition:
|
|
78
|
-
originalTransformOrigin:
|
|
76
|
+
originalTransform: Y,
|
|
77
|
+
originalPosition: m,
|
|
78
|
+
originalTransformOrigin: E
|
|
79
79
|
};
|
|
80
80
|
}).filter(Boolean);
|
|
81
|
-
return i = null,
|
|
81
|
+
return i = null, y.length === 0 ? {
|
|
82
82
|
spring: n,
|
|
83
83
|
tick: () => {
|
|
84
84
|
}
|
|
@@ -86,35 +86,35 @@ const Y = (t = {}) => {
|
|
|
86
86
|
} : {
|
|
87
87
|
spring: n,
|
|
88
88
|
prepare: () => {
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
y.forEach(({ toEl: o }) => {
|
|
90
|
+
o.style.position = "relative", o.style.transformOrigin = "top left";
|
|
91
91
|
});
|
|
92
92
|
},
|
|
93
|
-
tick: (
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
tick: (o) => {
|
|
94
|
+
y.forEach(({ toEl: $, dx: c, dy: d, dw: w, dh: f }) => {
|
|
95
|
+
$.style.transform = `translate(${(1 - o) * c}px,${(1 - o) * d}px) scale(${o + (1 - o) * w}, ${o + (1 - o) * f})`;
|
|
96
96
|
});
|
|
97
97
|
},
|
|
98
98
|
onEnd: () => {
|
|
99
|
-
|
|
99
|
+
y.forEach(
|
|
100
100
|
({
|
|
101
|
-
toEl:
|
|
102
|
-
originalTransform:
|
|
103
|
-
originalPosition:
|
|
101
|
+
toEl: o,
|
|
102
|
+
originalTransform: $,
|
|
103
|
+
originalPosition: c,
|
|
104
104
|
originalTransformOrigin: d
|
|
105
105
|
}) => {
|
|
106
|
-
|
|
106
|
+
o.style.transform = $, o.style.position = c, o.style.transformOrigin = d;
|
|
107
107
|
}
|
|
108
108
|
);
|
|
109
109
|
}
|
|
110
110
|
};
|
|
111
111
|
},
|
|
112
|
-
out: async (
|
|
112
|
+
out: async (a) => ({
|
|
113
113
|
onStart: () => {
|
|
114
|
-
i =
|
|
114
|
+
i = a, s && (s(!0), s = null);
|
|
115
115
|
},
|
|
116
|
-
prepare: (
|
|
117
|
-
k(
|
|
116
|
+
prepare: (r) => {
|
|
117
|
+
k(r), r.style.opacity = "0";
|
|
118
118
|
}
|
|
119
119
|
})
|
|
120
120
|
};
|
|
@@ -128,39 +128,39 @@ function S(t, n) {
|
|
|
128
128
|
i.height
|
|
129
129
|
);
|
|
130
130
|
}
|
|
131
|
-
function
|
|
131
|
+
function C({
|
|
132
132
|
detailRect: t,
|
|
133
133
|
galleryRect: n,
|
|
134
134
|
pageRect: e,
|
|
135
135
|
scrollOffset: i
|
|
136
136
|
}, s) {
|
|
137
|
-
const l = n.left - t.left + (n.width - t.width) / 2 - i.x,
|
|
138
|
-
return s.style.transformOrigin = `${t.left + t.width / 2}px ${t.top + t.height / 2}px`, (
|
|
139
|
-
const
|
|
140
|
-
s.style.clipPath = `inset(${d}% ${
|
|
137
|
+
const l = n.left - t.left + (n.width - t.width) / 2 - i.x, h = n.top - t.top + (n.height - t.height) / 2 - i.y, a = n.width / t.width, r = n.height / t.height, u = Math.max(a, r), g = t.top / e.height * 100, p = (e.width - (t.left + t.width)) / e.width * 100, y = (e.height - (t.top + t.height)) / e.height * 100, o = t.left / e.width * 100;
|
|
138
|
+
return s.style.transformOrigin = `${t.left + t.width / 2}px ${t.top + t.height / 2}px`, ($) => {
|
|
139
|
+
const c = 1 - $, d = g * c, w = p * c, f = y * c, x = o * c;
|
|
140
|
+
s.style.clipPath = `inset(${d}% ${w}% ${f}% ${x}%)`, s.style.transform = `translate(${l * c}px, ${h * c}px) scale(${1 + (u - 1) * c})`;
|
|
141
141
|
};
|
|
142
142
|
}
|
|
143
|
-
function
|
|
143
|
+
function D({
|
|
144
144
|
galleryRect: t,
|
|
145
145
|
detailRect: n,
|
|
146
146
|
scrollOffset: e
|
|
147
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,
|
|
149
|
-
return (
|
|
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, h = n.width / t.width, a = n.height / t.height, r = Math.max(h, a);
|
|
149
|
+
return (u) => {
|
|
150
150
|
i.style.transformOrigin = `${t.left + t.width / 2}px ${t.top + t.height / 2}px`;
|
|
151
|
-
const g = 1 -
|
|
152
|
-
i.style.transform = `translate(${s * g - e.x}px, ${l * g - e.y}px) scale(${1 + (
|
|
151
|
+
const g = 1 - u;
|
|
152
|
+
i.style.transform = `translate(${s * g - e.x}px, ${l * g - e.y}px) scale(${1 + (r - 1) * g})`, i.style.opacity = `${1 - g}`;
|
|
153
153
|
};
|
|
154
154
|
}
|
|
155
|
-
function
|
|
155
|
+
function P({
|
|
156
156
|
galleryRect: t,
|
|
157
157
|
detailRect: n,
|
|
158
158
|
scrollOffset: e
|
|
159
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,
|
|
161
|
-
return (
|
|
162
|
-
const g = 1 -
|
|
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 + (
|
|
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, h = n.width / t.width, a = n.height / t.height, r = Math.max(h, a);
|
|
161
|
+
return (u) => {
|
|
162
|
+
const g = 1 - u, p = u;
|
|
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 + (r - 1) * g})`, i.style.opacity = `${p}`;
|
|
164
164
|
};
|
|
165
165
|
}
|
|
166
166
|
function F({
|
|
@@ -169,13 +169,13 @@ function F({
|
|
|
169
169
|
pageRect: e,
|
|
170
170
|
scrollOffset: i
|
|
171
171
|
}, s) {
|
|
172
|
-
const l = n.left - t.left + (n.width - t.width) / 2 + i.x,
|
|
173
|
-
return s.style.transformOrigin = `${t.left + t.width / 2}px ${t.top + t.height / 2}px`, (
|
|
174
|
-
const
|
|
175
|
-
s.style.clipPath = `inset(${d}% ${
|
|
172
|
+
const l = n.left - t.left + (n.width - t.width) / 2 + i.x, h = n.top - t.top + (n.height - t.height) / 2 + i.y, a = n.width / t.width, r = n.height / t.height, u = Math.min(a, r), g = t.top / e.height * 100, p = (e.width - (t.left + t.width)) / e.width * 100, y = (e.height - (t.top + t.height)) / e.height * 100, o = t.left / e.width * 100;
|
|
173
|
+
return s.style.transformOrigin = `${t.left + t.width / 2}px ${t.top + t.height / 2}px`, ($) => {
|
|
174
|
+
const c = 1 - $, d = g * c, w = p * c, f = y * c, x = o * c;
|
|
175
|
+
s.style.clipPath = `inset(${d}% ${w}% ${f}% ${x}%)`, s.style.transform = `translate(${l * c - i.x}px, ${h * c - i.y}px) scale(${1 + (u - 1) * c})`;
|
|
176
176
|
};
|
|
177
177
|
}
|
|
178
|
-
function
|
|
178
|
+
function L(t, n, e) {
|
|
179
179
|
const i = t.querySelector(
|
|
180
180
|
"[data-pinterest-detail-key]"
|
|
181
181
|
), s = n.querySelector(
|
|
@@ -183,67 +183,67 @@ function I(t, n, e) {
|
|
|
183
183
|
);
|
|
184
184
|
if (t.querySelectorAll("[data-pinterest-detail-key]").length > 1 || n.querySelectorAll("[data-pinterest-detail-key]").length > 1)
|
|
185
185
|
return null;
|
|
186
|
-
let l = null,
|
|
186
|
+
let l = null, h = null, a = !1;
|
|
187
187
|
if (!i && s) {
|
|
188
|
-
|
|
189
|
-
const
|
|
190
|
-
if (!
|
|
188
|
+
h = s;
|
|
189
|
+
const p = h.getAttribute("data-pinterest-detail-key");
|
|
190
|
+
if (!p) return null;
|
|
191
191
|
l = t.querySelector(
|
|
192
|
-
`[data-pinterest-gallery-key="${
|
|
193
|
-
), l && (
|
|
192
|
+
`[data-pinterest-gallery-key="${p}"]`
|
|
193
|
+
), l && (a = !0);
|
|
194
194
|
} else if (i && !s) {
|
|
195
|
-
|
|
196
|
-
const
|
|
197
|
-
if (!
|
|
195
|
+
h = i;
|
|
196
|
+
const p = h.getAttribute("data-pinterest-detail-key");
|
|
197
|
+
if (!p) return null;
|
|
198
198
|
l = n.querySelector(
|
|
199
|
-
`[data-pinterest-gallery-key="${
|
|
200
|
-
), l && (
|
|
199
|
+
`[data-pinterest-gallery-key="${p}"]`
|
|
200
|
+
), l && (a = !1);
|
|
201
201
|
}
|
|
202
|
-
if (!l || !
|
|
202
|
+
if (!l || !h)
|
|
203
203
|
return null;
|
|
204
|
-
const
|
|
205
|
-
return
|
|
206
|
-
inAnimation:
|
|
207
|
-
{ detailRect:
|
|
204
|
+
const r = S(a ? t : n, l), u = S(a ? n : t, h), g = n.getBoundingClientRect();
|
|
205
|
+
return a ? {
|
|
206
|
+
inAnimation: C(
|
|
207
|
+
{ detailRect: u, galleryRect: r, pageRect: g, scrollOffset: e },
|
|
208
208
|
n
|
|
209
209
|
),
|
|
210
|
-
outAnimation:
|
|
211
|
-
{ galleryRect:
|
|
210
|
+
outAnimation: D(
|
|
211
|
+
{ galleryRect: r, detailRect: u, scrollOffset: e },
|
|
212
212
|
t
|
|
213
213
|
)
|
|
214
214
|
} : {
|
|
215
|
-
inAnimation:
|
|
216
|
-
{ galleryRect:
|
|
215
|
+
inAnimation: P(
|
|
216
|
+
{ galleryRect: r, detailRect: u, scrollOffset: e },
|
|
217
217
|
n
|
|
218
218
|
),
|
|
219
219
|
outAnimation: F(
|
|
220
|
-
{ detailRect:
|
|
220
|
+
{ detailRect: u, galleryRect: r, pageRect: g, scrollOffset: e },
|
|
221
221
|
t
|
|
222
222
|
)
|
|
223
223
|
};
|
|
224
224
|
}
|
|
225
|
-
const
|
|
226
|
-
var
|
|
225
|
+
const I = (t = {}) => {
|
|
226
|
+
var h, a;
|
|
227
227
|
const n = {
|
|
228
|
-
stiffness: ((
|
|
229
|
-
damping: ((
|
|
228
|
+
stiffness: ((h = t.spring) == null ? void 0 : h.stiffness) ?? 50,
|
|
229
|
+
damping: ((a = t.spring) == null ? void 0 : a.damping) ?? 10
|
|
230
230
|
}, e = t.timeout ?? 300;
|
|
231
231
|
let i = null, s = null, l = null;
|
|
232
232
|
return {
|
|
233
|
-
in: async (
|
|
234
|
-
const g =
|
|
235
|
-
return !await new Promise((
|
|
236
|
-
i ?
|
|
237
|
-
s = null,
|
|
233
|
+
in: async (r, { scrollOffset: u }) => {
|
|
234
|
+
const g = r;
|
|
235
|
+
return !await new Promise((y) => {
|
|
236
|
+
i ? y(!0) : (s = y, setTimeout(() => {
|
|
237
|
+
s = null, y(!1);
|
|
238
238
|
}, e));
|
|
239
239
|
}) || !i ? (i = null, {
|
|
240
240
|
spring: n,
|
|
241
241
|
tick: () => {
|
|
242
242
|
}
|
|
243
|
-
}) : (l =
|
|
243
|
+
}) : (l = L(i, g, u), l ? (i = null, {
|
|
244
244
|
spring: n,
|
|
245
|
-
tick: (
|
|
246
|
-
l && l.inAnimation(
|
|
245
|
+
tick: (y) => {
|
|
246
|
+
l && l.inAnimation(y);
|
|
247
247
|
}
|
|
248
248
|
}) : {
|
|
249
249
|
spring: n,
|
|
@@ -251,55 +251,46 @@ const m = (t = {}) => {
|
|
|
251
251
|
}
|
|
252
252
|
});
|
|
253
253
|
},
|
|
254
|
-
out: async (
|
|
254
|
+
out: async (r) => ({
|
|
255
255
|
spring: n,
|
|
256
256
|
onStart: () => {
|
|
257
|
-
i =
|
|
257
|
+
i = r, s && (s(!0), s = null);
|
|
258
258
|
},
|
|
259
|
-
prepare: (
|
|
260
|
-
k(
|
|
259
|
+
prepare: (u) => {
|
|
260
|
+
k(u), u.style.zIndex = "-1";
|
|
261
261
|
},
|
|
262
|
-
tick: (
|
|
263
|
-
l && l.outAnimation(
|
|
262
|
+
tick: (u) => {
|
|
263
|
+
l && l.outAnimation(u);
|
|
264
264
|
}
|
|
265
265
|
})
|
|
266
266
|
};
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
const n = t.
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
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
|
-
};
|
|
267
|
+
}, G = (t = {}) => {
|
|
268
|
+
var s, l;
|
|
269
|
+
const n = t.direction ?? "up", e = {
|
|
270
|
+
stiffness: ((s = t.spring) == null ? void 0 : s.stiffness) ?? 300,
|
|
271
|
+
damping: ((l = t.spring) == null ? void 0 : l.damping) ?? 30
|
|
272
|
+
}, i = n === "up";
|
|
278
273
|
return {
|
|
279
|
-
in: (
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
},
|
|
295
|
-
prepare: k
|
|
296
|
-
};
|
|
297
|
-
}
|
|
274
|
+
in: (h) => ({
|
|
275
|
+
spring: e,
|
|
276
|
+
tick: (a) => {
|
|
277
|
+
const r = i ? (1 - a) * 100 : (1 - a) * -100;
|
|
278
|
+
h.style.transform = `translateY(${r}%)`;
|
|
279
|
+
}
|
|
280
|
+
}),
|
|
281
|
+
out: (h) => ({
|
|
282
|
+
spring: e,
|
|
283
|
+
tick: (a) => {
|
|
284
|
+
const r = i ? (1 - a) * -100 : (1 - a) * 100;
|
|
285
|
+
h.style.transform = `translateY(${r}%)`;
|
|
286
|
+
},
|
|
287
|
+
prepare: k
|
|
288
|
+
})
|
|
298
289
|
};
|
|
299
290
|
};
|
|
300
291
|
export {
|
|
301
292
|
X as fade,
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
293
|
+
b as hero,
|
|
294
|
+
I as pinterest,
|
|
295
|
+
G as scroll
|
|
305
296
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SpringConfig, SggoiTransition } from '../types';
|
|
2
|
+
interface ScrollOptions {
|
|
3
|
+
direction?: "up" | "down";
|
|
4
|
+
spring?: Partial<SpringConfig>;
|
|
5
|
+
}
|
|
6
|
+
export declare const scroll: (options?: ScrollOptions) => SggoiTransition;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=scroll.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scroll.d.ts","sourceRoot":"","sources":["../../src/lib/view-transitions/scroll.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG9D,UAAU,aAAa;IACrB,SAAS,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IAC1B,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;CAChC;AAED,eAAO,MAAM,MAAM,GAAI,UAAS,aAAkB,KAAG,eA8BpD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ssgoi/core",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Core animation engine for SSGOI - Native app-like page transitions with spring physics",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/index.cjs",
|
|
@@ -11,22 +11,32 @@
|
|
|
11
11
|
".": {
|
|
12
12
|
"types": "./dist/index.d.ts",
|
|
13
13
|
"import": "./dist/index.js",
|
|
14
|
-
"require": "./dist/index.cjs"
|
|
14
|
+
"require": "./dist/index.cjs",
|
|
15
|
+
"default": "./dist/index.js"
|
|
15
16
|
},
|
|
16
17
|
"./transitions": {
|
|
17
18
|
"types": "./dist/transitions/index.d.ts",
|
|
18
19
|
"import": "./dist/transitions/index.js",
|
|
19
|
-
"require": "./dist/transitions/index.cjs"
|
|
20
|
+
"require": "./dist/transitions/index.cjs",
|
|
21
|
+
"default": "./dist/transitions/index.js"
|
|
20
22
|
},
|
|
21
23
|
"./view-transitions": {
|
|
22
24
|
"types": "./dist/view-transitions/index.d.ts",
|
|
23
25
|
"import": "./dist/view-transitions/index.js",
|
|
24
|
-
"require": "./dist/view-transitions/index.cjs"
|
|
26
|
+
"require": "./dist/view-transitions/index.cjs",
|
|
27
|
+
"default": "./dist/view-transitions/index.js"
|
|
25
28
|
},
|
|
26
29
|
"./types": {
|
|
27
30
|
"types": "./dist/types.d.ts",
|
|
28
31
|
"import": "./dist/types.js",
|
|
29
|
-
"require": "./dist/types.cjs"
|
|
32
|
+
"require": "./dist/types.cjs",
|
|
33
|
+
"default": "./dist/types.js"
|
|
34
|
+
},
|
|
35
|
+
"./presets": {
|
|
36
|
+
"types": "./dist/presets/index.d.ts",
|
|
37
|
+
"import": "./dist/presets/index.js",
|
|
38
|
+
"require": "./dist/presets/index.cjs",
|
|
39
|
+
"default": "./dist/presets/index.js"
|
|
30
40
|
}
|
|
31
41
|
},
|
|
32
42
|
"files": [
|
|
@@ -42,13 +52,23 @@
|
|
|
42
52
|
"spring-physics",
|
|
43
53
|
"ssgoi"
|
|
44
54
|
],
|
|
45
|
-
"author": "",
|
|
55
|
+
"author": "MeurSyphus <tmdeoans@snu.ac.kr>",
|
|
46
56
|
"license": "MIT",
|
|
47
57
|
"repository": {
|
|
48
58
|
"type": "git",
|
|
49
|
-
"url": "https://github.com/
|
|
59
|
+
"url": "git+https://github.com/meursyphus/ssgoi.git",
|
|
50
60
|
"directory": "packages/core"
|
|
51
61
|
},
|
|
62
|
+
"homepage": "https://ssgoi.dev",
|
|
63
|
+
"bugs": {
|
|
64
|
+
"url": "https://github.com/meursyphus/ssgoi/issues"
|
|
65
|
+
},
|
|
66
|
+
"publishConfig": {
|
|
67
|
+
"access": "public"
|
|
68
|
+
},
|
|
69
|
+
"engines": {
|
|
70
|
+
"node": ">=18.0.0"
|
|
71
|
+
},
|
|
52
72
|
"devDependencies": {
|
|
53
73
|
"@types/node": "^22.10.6",
|
|
54
74
|
"typescript": "^5.7.3",
|
|
@@ -60,6 +80,7 @@
|
|
|
60
80
|
},
|
|
61
81
|
"scripts": {
|
|
62
82
|
"dev": "vite",
|
|
83
|
+
"watch": "vite build --watch",
|
|
63
84
|
"build": "tsc && vite build",
|
|
64
85
|
"preview": "vite preview"
|
|
65
86
|
}
|