@ssgoi/react 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.
- package/README.md +265 -0
- package/dist/context.d.ts +3 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +770 -0
- package/dist/ssgoi-transition.d.ts +5 -0
- package/dist/ssgoi.d.ts +8 -0
- package/dist/transition.d.ts +2 -0
- package/dist/transitions/index.cjs +1 -0
- package/dist/transitions/index.d.ts +1 -0
- package/dist/transitions/index.js +173 -0
- package/dist/types.cjs +1 -0
- package/dist/types.d.ts +1 -0
- package/dist/types.js +1 -0
- package/dist/utils-BSgyev81.cjs +1 -0
- package/dist/utils-DR41YsAh.js +16 -0
- package/dist/view-transitions/index.cjs +1 -0
- package/dist/view-transitions/index.d.ts +1 -0
- package/dist/view-transitions/index.js +301 -0
- package/package.json +47 -0
package/dist/ssgoi.d.ts
ADDED
|
@@ -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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@ssgoi/core/transitions';
|
|
@@ -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
|
+
};
|
package/dist/types.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@ssgoi/core/types';
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const n=e=>{e.style.position="absolute",e.style.width="100%",e.style.top="0",e.style.left="0"},r=e=>{let t=e.parentElement;for(;t&&t!==document.body;){const l=window.getComputedStyle(t),o=l.overflow+l.overflowY+l.overflowX;if(o.includes("auto")||o.includes("scroll")||t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth)return t;t=t.parentElement}return document.documentElement};exports.getScrollingElement=r;exports.prepareOutgoing=n;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const n = (e) => {
|
|
2
|
+
e.style.position = "absolute", e.style.width = "100%", e.style.top = "0", e.style.left = "0";
|
|
3
|
+
}, r = (e) => {
|
|
4
|
+
let t = e.parentElement;
|
|
5
|
+
for (; t && t !== document.body; ) {
|
|
6
|
+
const o = window.getComputedStyle(t), l = o.overflow + o.overflowY + o.overflowX;
|
|
7
|
+
if (l.includes("auto") || l.includes("scroll") || t.scrollHeight > t.clientHeight || t.scrollWidth > t.clientWidth)
|
|
8
|
+
return t;
|
|
9
|
+
t = t.parentElement;
|
|
10
|
+
}
|
|
11
|
+
return document.documentElement;
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
r as g,
|
|
15
|
+
n as p
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("../utils-BSgyev81.cjs"),P=(t={})=>{const n={stiffness:t.spring?.stiffness??300,damping:t.spring?.damping??30};return{in:e=>({spring:n,tick:i=>{e.style.opacity=i.toString()}}),out:e=>({spring:n,tick:i=>{e.style.opacity=i.toString()},prepare:k.prepareOutgoing})}};function b(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={})=>{const n={stiffness:t.spring?.stiffness??300,damping:t.spring?.damping??30},e=t.timeout??300;let i=null,s=null;return{in:async(a,h)=>{const o=a,c=Array.from(o.querySelectorAll("[data-hero-key]"));if(c.length===0)return{spring:n,tick:()=>{}};if(!await new Promise(l=>{i?l(!0):(s=l,setTimeout(()=>{s=null,l(!1)},e))})||!i)return i=null,{spring:n,tick:()=>{}};const r=c.map(l=>{const y=l.getAttribute("data-hero-key");if(!y)return null;const d=b(i,y);if(!d)return null;const p=l,u=A(i,d),f=A(o,p),$=u.left-f.left-h.scrollOffset.x,w=u.top-f.top-h.scrollOffset.y,x=u.width/f.width,M=u.height/f.height,q=p.style.transform,O=p.style.position,T=p.style.transformOrigin;return{toEl:p,dx:$,dy:w,dw:x,dh:M,originalTransform:q,originalPosition:O,originalTransformOrigin:T}}).filter(Boolean);return i=null,r.length===0?{spring:n,tick:()=>{}}:{spring:n,prepare:()=>{r.forEach(({toEl:l})=>{l.style.position="relative",l.style.transformOrigin="top left"})},tick:l=>{r.forEach(({toEl:y,dx:d,dy:p,dw:u,dh:f})=>{y.style.transform=`translate(${(1-l)*d}px,${(1-l)*p}px) scale(${l+(1-l)*u}, ${l+(1-l)*f})`})},onEnd:()=>{r.forEach(({toEl:l,originalTransform:y,originalPosition:d,originalTransformOrigin:p})=>{l.style.transform=y,l.style.position=d,l.style.transformOrigin=p})}}},out:async a=>({onStart:()=>{i=a,s&&(s(!0),s=null)},prepare:h=>{k.prepareOutgoing(h),h.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 E({detailRect:t,galleryRect:n,pageRect:e,scrollOffset:i},s){const a=n.left-t.left+(n.width-t.width)/2-i.x,h=n.top-t.top+(n.height-t.height)/2-i.y,o=n.width/t.width,c=n.height/t.height,g=Math.max(o,c),r=t.top/e.height*100,l=(e.width-(t.left+t.width))/e.width*100,y=(e.height-(t.top+t.height))/e.height*100,d=t.left/e.width*100;return s.style.transformOrigin=`${t.left+t.width/2}px ${t.top+t.height/2}px`,p=>{const u=1-p,f=r*u,$=l*u,w=y*u,x=d*u;s.style.clipPath=`inset(${f}% ${$}% ${w}% ${x}%)`,s.style.transform=`translate(${a*u}px, ${h*u}px) scale(${1+(g-1)*u})`}}function D({galleryRect:t,detailRect:n,scrollOffset:e},i){const s=n.left-t.left+(n.width-t.width)/2+e.x,a=n.top-t.top+(n.height-t.height)/2+e.y,h=n.width/t.width,o=n.height/t.height,c=Math.max(h,o);return g=>{i.style.transformOrigin=`${t.left+t.width/2}px ${t.top+t.height/2}px`;const r=1-g;i.style.transform=`translate(${s*r-e.x}px, ${a*r-e.y}px) scale(${1+(c-1)*r})`,i.style.opacity=`${1-r}`}}function H({galleryRect:t,detailRect:n,scrollOffset:e},i){const s=n.left-t.left+(n.width-t.width)/2-e.x,a=n.top-t.top+(n.height-t.height)/2-e.y,h=n.width/t.width,o=n.height/t.height,c=Math.max(h,o);return g=>{const r=1-g,l=g;i.style.transformOrigin=`${t.left+t.width/2}px ${t.top+t.height/2}px`,i.style.transform=`translate(${s*r}px, ${a*r}px) scale(${1+(c-1)*r})`,i.style.opacity=`${l}`}}function F({detailRect:t,galleryRect:n,pageRect:e,scrollOffset:i},s){const a=n.left-t.left+(n.width-t.width)/2+i.x,h=n.top-t.top+(n.height-t.height)/2+i.y,o=n.width/t.width,c=n.height/t.height,g=Math.min(o,c),r=t.top/e.height*100,l=(e.width-(t.left+t.width))/e.width*100,y=(e.height-(t.top+t.height))/e.height*100,d=t.left/e.width*100;return s.style.transformOrigin=`${t.left+t.width/2}px ${t.top+t.height/2}px`,p=>{const u=1-p,f=r*u,$=l*u,w=y*u,x=d*u;s.style.clipPath=`inset(${f}% ${$}% ${w}% ${x}%)`,s.style.transform=`translate(${a*u-i.x}px, ${h*u-i.y}px) scale(${1+(g-1)*u})`}}function I(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 a=null,h=null,o=!1;if(!i&&s){h=s;const l=h.getAttribute("data-pinterest-detail-key");if(!l)return null;a=t.querySelector(`[data-pinterest-gallery-key="${l}"]`),a&&(o=!0)}else if(i&&!s){h=i;const l=h.getAttribute("data-pinterest-detail-key");if(!l)return null;a=n.querySelector(`[data-pinterest-gallery-key="${l}"]`),a&&(o=!1)}if(!a||!h)return null;const c=S(o?t:n,a),g=S(o?n:t,h),r=n.getBoundingClientRect();return o?{inAnimation:E({detailRect:g,galleryRect:c,pageRect:r,scrollOffset:e},n),outAnimation:D({galleryRect:c,detailRect:g,scrollOffset:e},t)}:{inAnimation:H({galleryRect:c,detailRect:g,scrollOffset:e},n),outAnimation:F({detailRect:g,galleryRect:c,pageRect:r,scrollOffset:e},t)}}const L=(t={})=>{const n={stiffness:t.spring?.stiffness??50,damping:t.spring?.damping??10},e=t.timeout??300;let i=null,s=null,a=null;return{in:async(h,{scrollOffset:o})=>{const c=h;return!await new Promise(r=>{i?r(!0):(s=r,setTimeout(()=>{s=null,r(!1)},e))})||!i?(i=null,{spring:n,tick:()=>{}}):(a=I(i,c,o),a?(i=null,{spring:n,tick:r=>{a&&a.inAnimation(r)}}):{spring:n,tick:()=>{}})},out:async h=>({spring:n,onStart:()=>{i=h,s&&(s(!0),s=null)},prepare:o=>{k.prepareOutgoing(o),o.style.zIndex="-1"},tick:o=>{a&&a.outAnimation(o)}})}};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 X=(t={})=>{const n={stiffness:t.spring?.stiffness??300,damping:t.spring?.damping??200};return{in:e=>{const i=B(e);return{spring:n,tick:s=>{e.style.clipPath=`circle(${s*100}% at 50% ${i}%)`}}},out:e=>{const i=B(e);return{spring:n,tick:s=>{e.style.clipPath=`circle(${s*100}% at 50% ${i}%)`,e.style.zIndex="100"},prepare:k.prepareOutgoing}}}};exports.fade=P;exports.hero=C;exports.pinterest=L;exports.ripple=X;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@ssgoi/core/view-transitions';
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import { p as k } from "../utils-DR41YsAh.js";
|
|
2
|
+
const I = (t = {}) => {
|
|
3
|
+
const n = {
|
|
4
|
+
stiffness: t.spring?.stiffness ?? 300,
|
|
5
|
+
damping: t.spring?.damping ?? 30
|
|
6
|
+
};
|
|
7
|
+
return {
|
|
8
|
+
in: (e) => ({
|
|
9
|
+
spring: n,
|
|
10
|
+
tick: (i) => {
|
|
11
|
+
e.style.opacity = i.toString();
|
|
12
|
+
}
|
|
13
|
+
}),
|
|
14
|
+
out: (e) => ({
|
|
15
|
+
spring: n,
|
|
16
|
+
tick: (i) => {
|
|
17
|
+
e.style.opacity = i.toString();
|
|
18
|
+
},
|
|
19
|
+
prepare: k
|
|
20
|
+
})
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
function E(t, n) {
|
|
24
|
+
return t.querySelector(`[data-hero-key="${n}"]`);
|
|
25
|
+
}
|
|
26
|
+
function A(t, n) {
|
|
27
|
+
const e = t.getBoundingClientRect(), i = n.getBoundingClientRect();
|
|
28
|
+
return new DOMRect(
|
|
29
|
+
i.left - e.left,
|
|
30
|
+
i.top - e.top,
|
|
31
|
+
i.width,
|
|
32
|
+
i.height
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
const L = (t = {}) => {
|
|
36
|
+
const n = {
|
|
37
|
+
stiffness: t.spring?.stiffness ?? 300,
|
|
38
|
+
damping: t.spring?.damping ?? 30
|
|
39
|
+
}, e = t.timeout ?? 300;
|
|
40
|
+
let i = null, s = null;
|
|
41
|
+
return {
|
|
42
|
+
in: async (a, h) => {
|
|
43
|
+
const o = a, c = Array.from(o.querySelectorAll("[data-hero-key]"));
|
|
44
|
+
if (c.length === 0)
|
|
45
|
+
return {
|
|
46
|
+
spring: n,
|
|
47
|
+
tick: () => {
|
|
48
|
+
}
|
|
49
|
+
// No hero elements, skip animation
|
|
50
|
+
};
|
|
51
|
+
if (!await new Promise((l) => {
|
|
52
|
+
i ? l(!0) : (s = l, setTimeout(() => {
|
|
53
|
+
s = null, l(!1);
|
|
54
|
+
}, e));
|
|
55
|
+
}) || !i)
|
|
56
|
+
return i = null, {
|
|
57
|
+
spring: n,
|
|
58
|
+
tick: () => {
|
|
59
|
+
}
|
|
60
|
+
// No fromNode, skip animation
|
|
61
|
+
};
|
|
62
|
+
const r = c.map((l) => {
|
|
63
|
+
const y = l.getAttribute("data-hero-key");
|
|
64
|
+
if (!y) return null;
|
|
65
|
+
const d = E(i, y);
|
|
66
|
+
if (!d) return null;
|
|
67
|
+
const p = l, u = A(i, d), f = A(o, p), $ = u.left - f.left - h.scrollOffset.x, w = u.top - f.top - h.scrollOffset.y, x = u.width / f.width, M = u.height / f.height, q = p.style.transform, T = p.style.position, C = p.style.transformOrigin;
|
|
68
|
+
return {
|
|
69
|
+
toEl: p,
|
|
70
|
+
dx: $,
|
|
71
|
+
dy: w,
|
|
72
|
+
dw: x,
|
|
73
|
+
dh: M,
|
|
74
|
+
originalTransform: q,
|
|
75
|
+
originalPosition: T,
|
|
76
|
+
originalTransformOrigin: C
|
|
77
|
+
};
|
|
78
|
+
}).filter(Boolean);
|
|
79
|
+
return i = null, r.length === 0 ? {
|
|
80
|
+
spring: n,
|
|
81
|
+
tick: () => {
|
|
82
|
+
}
|
|
83
|
+
// No matching hero elements
|
|
84
|
+
} : {
|
|
85
|
+
spring: n,
|
|
86
|
+
prepare: () => {
|
|
87
|
+
r.forEach(({ toEl: l }) => {
|
|
88
|
+
l.style.position = "relative", l.style.transformOrigin = "top left";
|
|
89
|
+
});
|
|
90
|
+
},
|
|
91
|
+
tick: (l) => {
|
|
92
|
+
r.forEach(({ toEl: y, dx: d, dy: p, dw: u, dh: f }) => {
|
|
93
|
+
y.style.transform = `translate(${(1 - l) * d}px,${(1 - l) * p}px) scale(${l + (1 - l) * u}, ${l + (1 - l) * f})`;
|
|
94
|
+
});
|
|
95
|
+
},
|
|
96
|
+
onEnd: () => {
|
|
97
|
+
r.forEach(
|
|
98
|
+
({
|
|
99
|
+
toEl: l,
|
|
100
|
+
originalTransform: y,
|
|
101
|
+
originalPosition: d,
|
|
102
|
+
originalTransformOrigin: p
|
|
103
|
+
}) => {
|
|
104
|
+
l.style.transform = y, l.style.position = d, l.style.transformOrigin = p;
|
|
105
|
+
}
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
},
|
|
110
|
+
out: async (a) => ({
|
|
111
|
+
onStart: () => {
|
|
112
|
+
i = a, s && (s(!0), s = null);
|
|
113
|
+
},
|
|
114
|
+
prepare: (h) => {
|
|
115
|
+
k(h), h.style.opacity = "0";
|
|
116
|
+
}
|
|
117
|
+
})
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
function S(t, n) {
|
|
121
|
+
const e = t.getBoundingClientRect(), i = n.getBoundingClientRect();
|
|
122
|
+
return new DOMRect(
|
|
123
|
+
i.left - e.left,
|
|
124
|
+
i.top - e.top,
|
|
125
|
+
i.width,
|
|
126
|
+
i.height
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
function P({
|
|
130
|
+
detailRect: t,
|
|
131
|
+
galleryRect: n,
|
|
132
|
+
pageRect: e,
|
|
133
|
+
scrollOffset: i
|
|
134
|
+
}, s) {
|
|
135
|
+
const a = n.left - t.left + (n.width - t.width) / 2 - i.x, h = n.top - t.top + (n.height - t.height) / 2 - i.y, o = n.width / t.width, c = n.height / t.height, g = Math.max(o, c), r = t.top / e.height * 100, l = (e.width - (t.left + t.width)) / e.width * 100, y = (e.height - (t.top + t.height)) / e.height * 100, d = t.left / e.width * 100;
|
|
136
|
+
return s.style.transformOrigin = `${t.left + t.width / 2}px ${t.top + t.height / 2}px`, (p) => {
|
|
137
|
+
const u = 1 - p, f = r * u, $ = l * u, w = y * u, x = d * u;
|
|
138
|
+
s.style.clipPath = `inset(${f}% ${$}% ${w}% ${x}%)`, s.style.transform = `translate(${a * u}px, ${h * u}px) scale(${1 + (g - 1) * u})`;
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
function D({
|
|
142
|
+
galleryRect: t,
|
|
143
|
+
detailRect: n,
|
|
144
|
+
scrollOffset: e
|
|
145
|
+
}, i) {
|
|
146
|
+
const s = n.left - t.left + (n.width - t.width) / 2 + e.x, a = n.top - t.top + (n.height - t.height) / 2 + e.y, h = n.width / t.width, o = n.height / t.height, c = Math.max(h, o);
|
|
147
|
+
return (g) => {
|
|
148
|
+
i.style.transformOrigin = `${t.left + t.width / 2}px ${t.top + t.height / 2}px`;
|
|
149
|
+
const r = 1 - g;
|
|
150
|
+
i.style.transform = `translate(${s * r - e.x}px, ${a * r - e.y}px) scale(${1 + (c - 1) * r})`, i.style.opacity = `${1 - r}`;
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
function H({
|
|
154
|
+
galleryRect: t,
|
|
155
|
+
detailRect: n,
|
|
156
|
+
scrollOffset: e
|
|
157
|
+
}, i) {
|
|
158
|
+
const s = n.left - t.left + (n.width - t.width) / 2 - e.x, a = n.top - t.top + (n.height - t.height) / 2 - e.y, h = n.width / t.width, o = n.height / t.height, c = Math.max(h, o);
|
|
159
|
+
return (g) => {
|
|
160
|
+
const r = 1 - g, l = g;
|
|
161
|
+
i.style.transformOrigin = `${t.left + t.width / 2}px ${t.top + t.height / 2}px`, i.style.transform = `translate(${s * r}px, ${a * r}px) scale(${1 + (c - 1) * r})`, i.style.opacity = `${l}`;
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
function b({
|
|
165
|
+
detailRect: t,
|
|
166
|
+
galleryRect: n,
|
|
167
|
+
pageRect: e,
|
|
168
|
+
scrollOffset: i
|
|
169
|
+
}, s) {
|
|
170
|
+
const a = n.left - t.left + (n.width - t.width) / 2 + i.x, h = n.top - t.top + (n.height - t.height) / 2 + i.y, o = n.width / t.width, c = n.height / t.height, g = Math.min(o, c), r = t.top / e.height * 100, l = (e.width - (t.left + t.width)) / e.width * 100, y = (e.height - (t.top + t.height)) / e.height * 100, d = t.left / e.width * 100;
|
|
171
|
+
return s.style.transformOrigin = `${t.left + t.width / 2}px ${t.top + t.height / 2}px`, (p) => {
|
|
172
|
+
const u = 1 - p, f = r * u, $ = l * u, w = y * u, x = d * u;
|
|
173
|
+
s.style.clipPath = `inset(${f}% ${$}% ${w}% ${x}%)`, s.style.transform = `translate(${a * u - i.x}px, ${h * u - i.y}px) scale(${1 + (g - 1) * u})`;
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
function O(t, n, e) {
|
|
177
|
+
const i = t.querySelector(
|
|
178
|
+
"[data-pinterest-detail-key]"
|
|
179
|
+
), s = n.querySelector(
|
|
180
|
+
"[data-pinterest-detail-key]"
|
|
181
|
+
);
|
|
182
|
+
if (t.querySelectorAll("[data-pinterest-detail-key]").length > 1 || n.querySelectorAll("[data-pinterest-detail-key]").length > 1)
|
|
183
|
+
return null;
|
|
184
|
+
let a = null, h = null, o = !1;
|
|
185
|
+
if (!i && s) {
|
|
186
|
+
h = s;
|
|
187
|
+
const l = h.getAttribute("data-pinterest-detail-key");
|
|
188
|
+
if (!l) return null;
|
|
189
|
+
a = t.querySelector(
|
|
190
|
+
`[data-pinterest-gallery-key="${l}"]`
|
|
191
|
+
), a && (o = !0);
|
|
192
|
+
} else if (i && !s) {
|
|
193
|
+
h = i;
|
|
194
|
+
const l = h.getAttribute("data-pinterest-detail-key");
|
|
195
|
+
if (!l) return null;
|
|
196
|
+
a = n.querySelector(
|
|
197
|
+
`[data-pinterest-gallery-key="${l}"]`
|
|
198
|
+
), a && (o = !1);
|
|
199
|
+
}
|
|
200
|
+
if (!a || !h)
|
|
201
|
+
return null;
|
|
202
|
+
const c = S(o ? t : n, a), g = S(o ? n : t, h), r = n.getBoundingClientRect();
|
|
203
|
+
return o ? {
|
|
204
|
+
inAnimation: P(
|
|
205
|
+
{ detailRect: g, galleryRect: c, pageRect: r, scrollOffset: e },
|
|
206
|
+
n
|
|
207
|
+
),
|
|
208
|
+
outAnimation: D(
|
|
209
|
+
{ galleryRect: c, detailRect: g, scrollOffset: e },
|
|
210
|
+
t
|
|
211
|
+
)
|
|
212
|
+
} : {
|
|
213
|
+
inAnimation: H(
|
|
214
|
+
{ galleryRect: c, detailRect: g, scrollOffset: e },
|
|
215
|
+
n
|
|
216
|
+
),
|
|
217
|
+
outAnimation: b(
|
|
218
|
+
{ detailRect: g, galleryRect: c, pageRect: r, scrollOffset: e },
|
|
219
|
+
t
|
|
220
|
+
)
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
const X = (t = {}) => {
|
|
224
|
+
const n = {
|
|
225
|
+
stiffness: t.spring?.stiffness ?? 50,
|
|
226
|
+
damping: t.spring?.damping ?? 10
|
|
227
|
+
}, e = t.timeout ?? 300;
|
|
228
|
+
let i = null, s = null, a = null;
|
|
229
|
+
return {
|
|
230
|
+
in: async (h, { scrollOffset: o }) => {
|
|
231
|
+
const c = h;
|
|
232
|
+
return !await new Promise((r) => {
|
|
233
|
+
i ? r(!0) : (s = r, setTimeout(() => {
|
|
234
|
+
s = null, r(!1);
|
|
235
|
+
}, e));
|
|
236
|
+
}) || !i ? (i = null, {
|
|
237
|
+
spring: n,
|
|
238
|
+
tick: () => {
|
|
239
|
+
}
|
|
240
|
+
}) : (a = O(i, c, o), a ? (i = null, {
|
|
241
|
+
spring: n,
|
|
242
|
+
tick: (r) => {
|
|
243
|
+
a && a.inAnimation(r);
|
|
244
|
+
}
|
|
245
|
+
}) : {
|
|
246
|
+
spring: n,
|
|
247
|
+
tick: () => {
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
},
|
|
251
|
+
out: async (h) => ({
|
|
252
|
+
spring: n,
|
|
253
|
+
onStart: () => {
|
|
254
|
+
i = h, s && (s(!0), s = null);
|
|
255
|
+
},
|
|
256
|
+
prepare: (o) => {
|
|
257
|
+
k(o), o.style.zIndex = "-1";
|
|
258
|
+
},
|
|
259
|
+
tick: (o) => {
|
|
260
|
+
a && a.outAnimation(o);
|
|
261
|
+
}
|
|
262
|
+
})
|
|
263
|
+
};
|
|
264
|
+
};
|
|
265
|
+
function B(t) {
|
|
266
|
+
const n = t.getBoundingClientRect(), e = t.clientHeight, s = 50 * (window.innerHeight - n.top) / e;
|
|
267
|
+
return Math.min(Math.max(s, 0), 100);
|
|
268
|
+
}
|
|
269
|
+
const Y = (t = {}) => {
|
|
270
|
+
const n = {
|
|
271
|
+
stiffness: t.spring?.stiffness ?? 300,
|
|
272
|
+
damping: t.spring?.damping ?? 200
|
|
273
|
+
};
|
|
274
|
+
return {
|
|
275
|
+
in: (e) => {
|
|
276
|
+
const i = B(e);
|
|
277
|
+
return {
|
|
278
|
+
spring: n,
|
|
279
|
+
tick: (s) => {
|
|
280
|
+
e.style.clipPath = `circle(${s * 100}% at 50% ${i}%)`;
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
},
|
|
284
|
+
out: (e) => {
|
|
285
|
+
const i = B(e);
|
|
286
|
+
return {
|
|
287
|
+
spring: n,
|
|
288
|
+
tick: (s) => {
|
|
289
|
+
e.style.clipPath = `circle(${s * 100}% at 50% ${i}%)`, e.style.zIndex = "100";
|
|
290
|
+
},
|
|
291
|
+
prepare: k
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
};
|
|
296
|
+
export {
|
|
297
|
+
I as fade,
|
|
298
|
+
L as hero,
|
|
299
|
+
X as pinterest,
|
|
300
|
+
Y as ripple
|
|
301
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ssgoi/react",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist"
|
|
7
|
+
],
|
|
8
|
+
"main": "./dist/ssgoi-react.umd.js",
|
|
9
|
+
"module": "./dist/ssgoi-react.es.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./dist/ssgoi-react.es.js",
|
|
14
|
+
"require": "./dist/ssgoi-react.umd.js",
|
|
15
|
+
"types": "./dist/index.d.ts"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"dev": "vite build --watch",
|
|
20
|
+
"build": "tsc -b && vite build",
|
|
21
|
+
"lint": "eslint .",
|
|
22
|
+
"preview": "vite preview",
|
|
23
|
+
"package": "vite build",
|
|
24
|
+
"postpublish": "node scripts/restore-package.js"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@ssgoi/core": "workspace:*"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
31
|
+
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@eslint/js": "^9.30.1",
|
|
35
|
+
"@types/react": "^19.1.8",
|
|
36
|
+
"@types/react-dom": "^19.1.6",
|
|
37
|
+
"@vitejs/plugin-react": "^4.6.0",
|
|
38
|
+
"eslint": "^9.30.1",
|
|
39
|
+
"eslint-plugin-react-hooks": "^5.2.0",
|
|
40
|
+
"eslint-plugin-react-refresh": "^0.4.20",
|
|
41
|
+
"globals": "^16.3.0",
|
|
42
|
+
"typescript": "~5.8.3",
|
|
43
|
+
"typescript-eslint": "^8.35.1",
|
|
44
|
+
"vite": "^7.0.4",
|
|
45
|
+
"vite-plugin-dts": "^4.5.4"
|
|
46
|
+
}
|
|
47
|
+
}
|