@ssgoi/react 0.0.7 → 2.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.
- package/README.md +12 -0
- package/dist/context.cjs +2 -0
- package/dist/context.js +12 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +6 -772
- package/dist/presets/index.cjs +1 -0
- package/dist/presets/index.d.ts +1 -0
- package/dist/presets/index.js +1 -0
- package/dist/ssgoi-transition.cjs +2 -0
- package/dist/ssgoi-transition.d.ts +7 -3
- package/dist/ssgoi-transition.js +26 -0
- package/dist/ssgoi.cjs +2 -0
- package/dist/ssgoi.js +15 -0
- package/dist/transition.d.ts +1 -2
- package/dist/transitions/index.cjs +1 -1
- package/dist/transitions/index.js +1 -173
- package/dist/view-transitions/index.cjs +1 -1
- package/dist/view-transitions/index.js +1 -305
- package/package.json +46 -10
- package/dist/utils-DR41YsAh-CN_CfgYX.cjs +0 -1
- package/dist/utils-DR41YsAh-mLT5vDuI.js +0 -16
- package/src/assets/react.svg +0 -1
- package/src/lib/context.tsx +0 -14
- package/src/lib/index.ts +0 -4
- package/src/lib/ssgoi-transition.tsx +0 -21
- package/src/lib/ssgoi.tsx +0 -20
- package/src/lib/transition.ts +0 -3
- package/src/lib/transitions/index.ts +0 -1
- package/src/lib/types.ts +0 -1
- package/src/lib/view-transitions/index.ts +0 -1
- package/src/vite-env.d.ts +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@ssgoi/core/presets");Object.keys(t).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@ssgoi/core/presets';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@ssgoi/core/presets";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),a=require("@ssgoi/core"),u=require("./context.cjs"),g=({children:n,id:t,as:o,className:e,...i})=>{const s=u.useSsgoi(),r=o||"div";return c.jsx(r,{ref:a.transition(s(t)),"data-ssgoi-transition":t,className:e,...i,children:n})};exports.SsgoiTransition=g;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
|
|
1
|
+
import { ReactNode, ElementType } from 'react';
|
|
2
|
+
type SsgoiTransitionProps<T extends ElementType = "div"> = {
|
|
3
3
|
children: ReactNode;
|
|
4
4
|
id: string;
|
|
5
|
-
|
|
5
|
+
as?: T;
|
|
6
|
+
className?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const SsgoiTransition: <T extends ElementType = "div">({ children, id, as, className, ...rest }: SsgoiTransitionProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
3
|
+
import { transition as e } from "@ssgoi/core";
|
|
4
|
+
import { useSsgoi as a } from "./context.js";
|
|
5
|
+
const u = ({
|
|
6
|
+
children: t,
|
|
7
|
+
id: o,
|
|
8
|
+
as: n,
|
|
9
|
+
className: i,
|
|
10
|
+
...r
|
|
11
|
+
}) => {
|
|
12
|
+
const s = a();
|
|
13
|
+
return /* @__PURE__ */ m(
|
|
14
|
+
n || "div",
|
|
15
|
+
{
|
|
16
|
+
ref: e(s(o)),
|
|
17
|
+
"data-ssgoi-transition": o,
|
|
18
|
+
className: i,
|
|
19
|
+
...r,
|
|
20
|
+
children: t
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
export {
|
|
25
|
+
u as SsgoiTransition
|
|
26
|
+
};
|
package/dist/ssgoi.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),s=require("react"),i=require("./context.cjs"),n=require("@ssgoi/core"),c=({config:e,children:t})=>{const o=s.useMemo(()=>n.createSggoiTransitionContext(e),[e]);return r.jsx(i.SsgoiProvider,{value:o,children:t})};exports.Ssgoi=c;
|
package/dist/ssgoi.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo as i } from "react";
|
|
4
|
+
import { SsgoiProvider as m } from "./context.js";
|
|
5
|
+
import { createSggoiTransitionContext as s } from "@ssgoi/core";
|
|
6
|
+
const x = ({ config: o, children: r }) => {
|
|
7
|
+
const t = i(
|
|
8
|
+
() => s(o),
|
|
9
|
+
[o]
|
|
10
|
+
);
|
|
11
|
+
return /* @__PURE__ */ e(m, { value: t, children: r });
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
x as Ssgoi
|
|
15
|
+
};
|
package/dist/transition.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const transition: typeof _transition;
|
|
1
|
+
export { transition } from '@ssgoi/core';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@ssgoi/core/transitions");Object.keys(t).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})});
|
|
@@ -1,173 +1 @@
|
|
|
1
|
-
|
|
2
|
-
const {
|
|
3
|
-
from: i = 0,
|
|
4
|
-
to: a = 1,
|
|
5
|
-
spring: r = { stiffness: 300, damping: 30 }
|
|
6
|
-
} = o;
|
|
7
|
-
return {
|
|
8
|
-
in: (e) => ({
|
|
9
|
-
spring: r,
|
|
10
|
-
tick: (n) => {
|
|
11
|
-
const t = i + (a - i) * n;
|
|
12
|
-
e.style.opacity = t.toString();
|
|
13
|
-
}
|
|
14
|
-
}),
|
|
15
|
-
out: (e) => ({
|
|
16
|
-
spring: r,
|
|
17
|
-
tick: (n) => {
|
|
18
|
-
const t = i + (a - i) * n;
|
|
19
|
-
e.style.opacity = t.toString();
|
|
20
|
-
}
|
|
21
|
-
})
|
|
22
|
-
};
|
|
23
|
-
}, g = (o = {}) => {
|
|
24
|
-
const {
|
|
25
|
-
from: i = 0,
|
|
26
|
-
to: a = 1,
|
|
27
|
-
spring: r = { stiffness: 300, damping: 30 }
|
|
28
|
-
} = o;
|
|
29
|
-
return {
|
|
30
|
-
in: (e) => ({
|
|
31
|
-
spring: r,
|
|
32
|
-
tick: (n) => {
|
|
33
|
-
const t = i + (a - i) * n;
|
|
34
|
-
e.style.transform = `scale(${t})`;
|
|
35
|
-
}
|
|
36
|
-
}),
|
|
37
|
-
out: (e) => ({
|
|
38
|
-
spring: r,
|
|
39
|
-
tick: (n) => {
|
|
40
|
-
const t = i + (a - i) * n;
|
|
41
|
-
e.style.transform = `scale(${t})`;
|
|
42
|
-
}
|
|
43
|
-
})
|
|
44
|
-
};
|
|
45
|
-
}, f = (o = {}) => {
|
|
46
|
-
const {
|
|
47
|
-
direction: i = "left",
|
|
48
|
-
distance: a = 100,
|
|
49
|
-
fade: r = !0,
|
|
50
|
-
spring: e = { stiffness: 400, damping: 35 }
|
|
51
|
-
} = o, n = (t) => {
|
|
52
|
-
const s = (1 - t) * a;
|
|
53
|
-
switch (i) {
|
|
54
|
-
case "left":
|
|
55
|
-
return `translateX(${-s}px)`;
|
|
56
|
-
case "right":
|
|
57
|
-
return `translateX(${s}px)`;
|
|
58
|
-
case "up":
|
|
59
|
-
return `translateY(${-s}px)`;
|
|
60
|
-
case "down":
|
|
61
|
-
return `translateY(${s}px)`;
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
return {
|
|
65
|
-
in: (t) => ({
|
|
66
|
-
spring: e,
|
|
67
|
-
tick: (s) => {
|
|
68
|
-
t.style.transform = n(s), r && (t.style.opacity = s.toString());
|
|
69
|
-
}
|
|
70
|
-
}),
|
|
71
|
-
out: (t) => ({
|
|
72
|
-
spring: e,
|
|
73
|
-
tick: (s) => {
|
|
74
|
-
t.style.transform = n(s), r && (t.style.opacity = s.toString());
|
|
75
|
-
}
|
|
76
|
-
})
|
|
77
|
-
};
|
|
78
|
-
}, u = (o = {}) => {
|
|
79
|
-
const {
|
|
80
|
-
degrees: i = 360,
|
|
81
|
-
clockwise: a = !0,
|
|
82
|
-
scale: r = !1,
|
|
83
|
-
fade: e = !1,
|
|
84
|
-
spring: n = { stiffness: 500, damping: 25 }
|
|
85
|
-
} = o, t = a ? i : -i;
|
|
86
|
-
return {
|
|
87
|
-
in: (s) => ({
|
|
88
|
-
spring: n,
|
|
89
|
-
tick: (c) => {
|
|
90
|
-
const p = [`rotate(${c * t}deg)`];
|
|
91
|
-
r && p.push(`scale(${c})`), s.style.transform = p.join(" "), e && (s.style.opacity = c.toString());
|
|
92
|
-
}
|
|
93
|
-
}),
|
|
94
|
-
out: (s) => ({
|
|
95
|
-
spring: n,
|
|
96
|
-
tick: (c) => {
|
|
97
|
-
const p = [`rotate(${c * t}deg)`];
|
|
98
|
-
r && p.push(`scale(${c})`), s.style.transform = p.join(" "), e && (s.style.opacity = c.toString());
|
|
99
|
-
}
|
|
100
|
-
})
|
|
101
|
-
};
|
|
102
|
-
}, y = (o = {}) => {
|
|
103
|
-
const {
|
|
104
|
-
height: i = 20,
|
|
105
|
-
scale: a = !0,
|
|
106
|
-
fade: r = !1,
|
|
107
|
-
spring: e = { stiffness: 800, damping: 15 }
|
|
108
|
-
} = o;
|
|
109
|
-
return {
|
|
110
|
-
in: (n) => ({
|
|
111
|
-
spring: e,
|
|
112
|
-
tick: (t) => {
|
|
113
|
-
const s = [], c = Math.sin(t * Math.PI) * i * (1 - t);
|
|
114
|
-
s.push(`translateY(${-c}px)`), a && s.push(`scale(${0.8 + t * 0.2})`), n.style.transform = s.join(" "), r && (n.style.opacity = t.toString());
|
|
115
|
-
}
|
|
116
|
-
}),
|
|
117
|
-
out: (n) => ({
|
|
118
|
-
spring: e,
|
|
119
|
-
tick: (t) => {
|
|
120
|
-
const s = [], c = Math.sin(t * Math.PI) * i * (1 - t);
|
|
121
|
-
s.push(`translateY(${-c}px)`), a && s.push(`scale(${0.8 + t * 0.2})`), n.style.transform = s.join(" "), r && (n.style.opacity = t.toString());
|
|
122
|
-
}
|
|
123
|
-
})
|
|
124
|
-
};
|
|
125
|
-
}, m = (o = {}) => {
|
|
126
|
-
const {
|
|
127
|
-
amount: i = 10,
|
|
128
|
-
scale: a = !1,
|
|
129
|
-
fade: r = !0,
|
|
130
|
-
spring: e = { stiffness: 300, damping: 30 }
|
|
131
|
-
} = o;
|
|
132
|
-
return {
|
|
133
|
-
in: (n) => ({
|
|
134
|
-
spring: e,
|
|
135
|
-
tick: (t) => {
|
|
136
|
-
const s = [`blur(${(1 - t) * i}px)`];
|
|
137
|
-
n.style.filter = s.join(" "), a && (n.style.transform = `scale(${0.8 + t * 0.2})`), r && (n.style.opacity = t.toString());
|
|
138
|
-
}
|
|
139
|
-
}),
|
|
140
|
-
out: (n) => ({
|
|
141
|
-
spring: e,
|
|
142
|
-
tick: (t) => {
|
|
143
|
-
const s = [`blur(${(1 - t) * i}px)`];
|
|
144
|
-
n.style.filter = s.join(" "), a && (n.style.transform = `scale(${0.8 + t * 0.2})`), r && (n.style.opacity = t.toString());
|
|
145
|
-
}
|
|
146
|
-
})
|
|
147
|
-
};
|
|
148
|
-
}, d = (o = {}) => {
|
|
149
|
-
const {
|
|
150
|
-
spring: i = { stiffness: 1e3, damping: 100 }
|
|
151
|
-
} = o;
|
|
152
|
-
return {
|
|
153
|
-
in: (a) => ({
|
|
154
|
-
spring: i,
|
|
155
|
-
tick: (r) => {
|
|
156
|
-
}
|
|
157
|
-
}),
|
|
158
|
-
out: (a) => ({
|
|
159
|
-
spring: i,
|
|
160
|
-
tick: (r) => {
|
|
161
|
-
}
|
|
162
|
-
})
|
|
163
|
-
};
|
|
164
|
-
};
|
|
165
|
-
export {
|
|
166
|
-
m as blur,
|
|
167
|
-
y as bounce,
|
|
168
|
-
l as fade,
|
|
169
|
-
d as none,
|
|
170
|
-
u as rotate,
|
|
171
|
-
g as scale,
|
|
172
|
-
f as slide
|
|
173
|
-
};
|
|
1
|
+
export * from "@ssgoi/core/transitions";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@ssgoi/core/view-transitions");Object.keys(t).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})});
|
|
@@ -1,305 +1 @@
|
|
|
1
|
-
|
|
2
|
-
const D = (t = {}) => {
|
|
3
|
-
var e, l;
|
|
4
|
-
const i = {
|
|
5
|
-
stiffness: ((e = t.spring) == null ? void 0 : e.stiffness) ?? 300,
|
|
6
|
-
damping: ((l = t.spring) == null ? void 0 : l.damping) ?? 30
|
|
7
|
-
};
|
|
8
|
-
return {
|
|
9
|
-
in: (r) => ({
|
|
10
|
-
spring: i,
|
|
11
|
-
tick: (n) => {
|
|
12
|
-
r.style.opacity = n.toString();
|
|
13
|
-
}
|
|
14
|
-
}),
|
|
15
|
-
out: (r) => ({
|
|
16
|
-
spring: i,
|
|
17
|
-
tick: (n) => {
|
|
18
|
-
r.style.opacity = n.toString();
|
|
19
|
-
},
|
|
20
|
-
prepare: x
|
|
21
|
-
})
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
function M(t, e) {
|
|
25
|
-
return t.querySelector(`[data-hero-key="${e}"]`);
|
|
26
|
-
}
|
|
27
|
-
function R(t, e) {
|
|
28
|
-
const l = t.getBoundingClientRect(), i = e.getBoundingClientRect();
|
|
29
|
-
return new DOMRect(
|
|
30
|
-
i.left - l.left,
|
|
31
|
-
i.top - l.top,
|
|
32
|
-
i.width,
|
|
33
|
-
i.height
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
const H = (t = {}) => {
|
|
37
|
-
var e, l;
|
|
38
|
-
const i = {
|
|
39
|
-
stiffness: ((e = t.spring) == null ? void 0 : e.stiffness) ?? 300,
|
|
40
|
-
damping: ((l = t.spring) == null ? void 0 : l.damping) ?? 30
|
|
41
|
-
}, r = t.timeout ?? 300;
|
|
42
|
-
let n = null, s = null;
|
|
43
|
-
return {
|
|
44
|
-
in: async (a, g) => {
|
|
45
|
-
const h = a, f = Array.from(h.querySelectorAll("[data-hero-key]"));
|
|
46
|
-
if (f.length === 0)
|
|
47
|
-
return {
|
|
48
|
-
spring: i,
|
|
49
|
-
tick: () => {
|
|
50
|
-
}
|
|
51
|
-
// No hero elements, skip animation
|
|
52
|
-
};
|
|
53
|
-
if (!await new Promise((c) => {
|
|
54
|
-
n ? c(!0) : (s = c, setTimeout(() => {
|
|
55
|
-
s = null, c(!1);
|
|
56
|
-
}, r));
|
|
57
|
-
}) || !n)
|
|
58
|
-
return n = null, {
|
|
59
|
-
spring: i,
|
|
60
|
-
tick: () => {
|
|
61
|
-
}
|
|
62
|
-
// No fromNode, skip animation
|
|
63
|
-
};
|
|
64
|
-
const p = f.map((c) => {
|
|
65
|
-
const u = c.getAttribute("data-hero-key");
|
|
66
|
-
if (!u) return null;
|
|
67
|
-
const d = M(n, u);
|
|
68
|
-
if (!d) return null;
|
|
69
|
-
const o = c, y = R(n, d), m = R(h, o), $ = y.left - m.left - g.scrollOffset.x, w = y.top - m.top - g.scrollOffset.y, A = y.width / m.width, v = y.height / m.height, S = o.style.transform, q = o.style.position, E = o.style.transformOrigin;
|
|
70
|
-
return {
|
|
71
|
-
toEl: o,
|
|
72
|
-
dx: $,
|
|
73
|
-
dy: w,
|
|
74
|
-
dw: A,
|
|
75
|
-
dh: v,
|
|
76
|
-
originalTransform: S,
|
|
77
|
-
originalPosition: q,
|
|
78
|
-
originalTransformOrigin: E
|
|
79
|
-
};
|
|
80
|
-
}).filter(Boolean);
|
|
81
|
-
return n = null, p.length === 0 ? {
|
|
82
|
-
spring: i,
|
|
83
|
-
tick: () => {
|
|
84
|
-
}
|
|
85
|
-
// No matching hero elements
|
|
86
|
-
} : {
|
|
87
|
-
spring: i,
|
|
88
|
-
prepare: () => {
|
|
89
|
-
p.forEach(({ toEl: c }) => {
|
|
90
|
-
c.style.position = "relative", c.style.transformOrigin = "top left";
|
|
91
|
-
});
|
|
92
|
-
},
|
|
93
|
-
tick: (c) => {
|
|
94
|
-
p.forEach(({ toEl: u, dx: d, dy: o, dw: y, dh: m }) => {
|
|
95
|
-
u.style.transform = `translate(${(1 - c) * d}px,${(1 - c) * o}px) scale(${c + (1 - c) * y}, ${c + (1 - c) * m})`;
|
|
96
|
-
});
|
|
97
|
-
},
|
|
98
|
-
onEnd: () => {
|
|
99
|
-
p.forEach(
|
|
100
|
-
({
|
|
101
|
-
toEl: c,
|
|
102
|
-
originalTransform: u,
|
|
103
|
-
originalPosition: d,
|
|
104
|
-
originalTransformOrigin: o
|
|
105
|
-
}) => {
|
|
106
|
-
c.style.transform = u, c.style.position = d, c.style.transformOrigin = o;
|
|
107
|
-
}
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
},
|
|
112
|
-
out: async (a) => ({
|
|
113
|
-
onStart: () => {
|
|
114
|
-
n = a, s && (s(!0), s = null);
|
|
115
|
-
},
|
|
116
|
-
prepare: (g) => {
|
|
117
|
-
x(g), g.style.opacity = "0";
|
|
118
|
-
}
|
|
119
|
-
})
|
|
120
|
-
};
|
|
121
|
-
};
|
|
122
|
-
function k(t, e) {
|
|
123
|
-
const l = t.getBoundingClientRect(), i = e.getBoundingClientRect();
|
|
124
|
-
return new DOMRect(
|
|
125
|
-
i.left - l.left,
|
|
126
|
-
i.top - l.top,
|
|
127
|
-
i.width,
|
|
128
|
-
i.height
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
function P({
|
|
132
|
-
detailRect: t,
|
|
133
|
-
galleryRect: e,
|
|
134
|
-
pageRect: l,
|
|
135
|
-
scrollOffset: i
|
|
136
|
-
}, r) {
|
|
137
|
-
const n = e.left - t.left + (e.width - t.width) / 2 - i.x, s = e.top - t.top + (e.height - t.height) / 2 - i.y, a = e.width / t.width, g = e.height / t.height, h = Math.max(a, g), f = t.top / l.height * 100, p = (l.width - (t.left + t.width)) / l.width * 100, c = (l.height - (t.top + t.height)) / l.height * 100, u = t.left / l.width * 100;
|
|
138
|
-
return r.style.transformOrigin = `${t.left + t.width / 2}px ${t.top + t.height / 2}px`, (d) => {
|
|
139
|
-
const o = 1 - d, y = f * o, m = p * o, $ = c * o, w = u * o;
|
|
140
|
-
r.style.clipPath = `inset(${y}% ${m}% ${$}% ${w}%)`, r.style.transform = `translate(${n * o}px, ${s * o}px) scale(${1 + (h - 1) * o})`;
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
function B({
|
|
144
|
-
galleryRect: t,
|
|
145
|
-
detailRect: e,
|
|
146
|
-
scrollOffset: l
|
|
147
|
-
}, i) {
|
|
148
|
-
const r = e.left - t.left + (e.width - t.width) / 2 + l.x, n = e.top - t.top + (e.height - t.height) / 2 + l.y, s = e.width / t.width, a = e.height / t.height, g = Math.max(s, a);
|
|
149
|
-
return (h) => {
|
|
150
|
-
i.style.transformOrigin = `${t.left + t.width / 2}px ${t.top + t.height / 2}px`;
|
|
151
|
-
const f = 1 - h;
|
|
152
|
-
i.style.transform = `translate(${r * f - l.x}px, ${n * f - l.y}px) scale(${1 + (g - 1) * f})`, i.style.opacity = `${1 - f}`;
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
function C({
|
|
156
|
-
galleryRect: t,
|
|
157
|
-
detailRect: e,
|
|
158
|
-
scrollOffset: l
|
|
159
|
-
}, i) {
|
|
160
|
-
const r = e.left - t.left + (e.width - t.width) / 2 - l.x, n = e.top - t.top + (e.height - t.height) / 2 - l.y, s = e.width / t.width, a = e.height / t.height, g = Math.max(s, a);
|
|
161
|
-
return (h) => {
|
|
162
|
-
const f = 1 - h, p = h;
|
|
163
|
-
i.style.transformOrigin = `${t.left + t.width / 2}px ${t.top + t.height / 2}px`, i.style.transform = `translate(${r * f}px, ${n * f}px) scale(${1 + (g - 1) * f})`, i.style.opacity = `${p}`;
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
function T({
|
|
167
|
-
detailRect: t,
|
|
168
|
-
galleryRect: e,
|
|
169
|
-
pageRect: l,
|
|
170
|
-
scrollOffset: i
|
|
171
|
-
}, r) {
|
|
172
|
-
const n = e.left - t.left + (e.width - t.width) / 2 + i.x, s = e.top - t.top + (e.height - t.height) / 2 + i.y, a = e.width / t.width, g = e.height / t.height, h = Math.min(a, g), f = t.top / l.height * 100, p = (l.width - (t.left + t.width)) / l.width * 100, c = (l.height - (t.top + t.height)) / l.height * 100, u = t.left / l.width * 100;
|
|
173
|
-
return r.style.transformOrigin = `${t.left + t.width / 2}px ${t.top + t.height / 2}px`, (d) => {
|
|
174
|
-
const o = 1 - d, y = f * o, m = p * o, $ = c * o, w = u * o;
|
|
175
|
-
r.style.clipPath = `inset(${y}% ${m}% ${$}% ${w}%)`, r.style.transform = `translate(${n * o - i.x}px, ${s * o - i.y}px) scale(${1 + (h - 1) * o})`;
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
function b(t, e, l) {
|
|
179
|
-
const i = t.querySelector(
|
|
180
|
-
"[data-pinterest-detail-key]"
|
|
181
|
-
), r = e.querySelector(
|
|
182
|
-
"[data-pinterest-detail-key]"
|
|
183
|
-
);
|
|
184
|
-
if (t.querySelectorAll("[data-pinterest-detail-key]").length > 1 || e.querySelectorAll("[data-pinterest-detail-key]").length > 1)
|
|
185
|
-
return null;
|
|
186
|
-
let n = null, s = null, a = !1;
|
|
187
|
-
if (!i && r) {
|
|
188
|
-
s = r;
|
|
189
|
-
const p = s.getAttribute("data-pinterest-detail-key");
|
|
190
|
-
if (!p) return null;
|
|
191
|
-
n = t.querySelector(
|
|
192
|
-
`[data-pinterest-gallery-key="${p}"]`
|
|
193
|
-
), n && (a = !0);
|
|
194
|
-
} else if (i && !r) {
|
|
195
|
-
s = i;
|
|
196
|
-
const p = s.getAttribute("data-pinterest-detail-key");
|
|
197
|
-
if (!p) return null;
|
|
198
|
-
n = e.querySelector(
|
|
199
|
-
`[data-pinterest-gallery-key="${p}"]`
|
|
200
|
-
), n && (a = !1);
|
|
201
|
-
}
|
|
202
|
-
if (!n || !s)
|
|
203
|
-
return null;
|
|
204
|
-
const g = k(a ? t : e, n), h = k(a ? e : t, s), f = e.getBoundingClientRect();
|
|
205
|
-
return a ? {
|
|
206
|
-
inAnimation: P(
|
|
207
|
-
{ detailRect: h, galleryRect: g, pageRect: f, scrollOffset: l },
|
|
208
|
-
e
|
|
209
|
-
),
|
|
210
|
-
outAnimation: B(
|
|
211
|
-
{ galleryRect: g, detailRect: h, scrollOffset: l },
|
|
212
|
-
t
|
|
213
|
-
)
|
|
214
|
-
} : {
|
|
215
|
-
inAnimation: C(
|
|
216
|
-
{ galleryRect: g, detailRect: h, scrollOffset: l },
|
|
217
|
-
e
|
|
218
|
-
),
|
|
219
|
-
outAnimation: T(
|
|
220
|
-
{ detailRect: h, galleryRect: g, pageRect: f, scrollOffset: l },
|
|
221
|
-
t
|
|
222
|
-
)
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
const I = (t = {}) => {
|
|
226
|
-
var e, l;
|
|
227
|
-
const i = {
|
|
228
|
-
stiffness: ((e = t.spring) == null ? void 0 : e.stiffness) ?? 50,
|
|
229
|
-
damping: ((l = t.spring) == null ? void 0 : l.damping) ?? 10
|
|
230
|
-
}, r = t.timeout ?? 300;
|
|
231
|
-
let n = null, s = null, a = null;
|
|
232
|
-
return {
|
|
233
|
-
in: async (g, { scrollOffset: h }) => {
|
|
234
|
-
const f = g;
|
|
235
|
-
return !await new Promise((p) => {
|
|
236
|
-
n ? p(!0) : (s = p, setTimeout(() => {
|
|
237
|
-
s = null, p(!1);
|
|
238
|
-
}, r));
|
|
239
|
-
}) || !n ? (n = null, {
|
|
240
|
-
spring: i,
|
|
241
|
-
tick: () => {
|
|
242
|
-
}
|
|
243
|
-
}) : (a = b(n, f, h), a ? (n = null, {
|
|
244
|
-
spring: i,
|
|
245
|
-
tick: (p) => {
|
|
246
|
-
a && a.inAnimation(p);
|
|
247
|
-
}
|
|
248
|
-
}) : {
|
|
249
|
-
spring: i,
|
|
250
|
-
tick: () => {
|
|
251
|
-
}
|
|
252
|
-
});
|
|
253
|
-
},
|
|
254
|
-
out: async (g) => ({
|
|
255
|
-
spring: i,
|
|
256
|
-
onStart: () => {
|
|
257
|
-
n = g, s && (s(!0), s = null);
|
|
258
|
-
},
|
|
259
|
-
prepare: (h) => {
|
|
260
|
-
x(h), h.style.zIndex = "-1";
|
|
261
|
-
},
|
|
262
|
-
tick: (h) => {
|
|
263
|
-
a && a.outAnimation(h);
|
|
264
|
-
}
|
|
265
|
-
})
|
|
266
|
-
};
|
|
267
|
-
};
|
|
268
|
-
function O(t) {
|
|
269
|
-
const e = t.getBoundingClientRect(), l = t.clientHeight, i = 50 * (window.innerHeight - e.top) / l;
|
|
270
|
-
return Math.min(Math.max(i, 0), 100);
|
|
271
|
-
}
|
|
272
|
-
const F = (t = {}) => {
|
|
273
|
-
var e, l;
|
|
274
|
-
const i = {
|
|
275
|
-
stiffness: ((e = t.spring) == null ? void 0 : e.stiffness) ?? 300,
|
|
276
|
-
damping: ((l = t.spring) == null ? void 0 : l.damping) ?? 200
|
|
277
|
-
};
|
|
278
|
-
return {
|
|
279
|
-
in: (r) => {
|
|
280
|
-
const n = O(r);
|
|
281
|
-
return {
|
|
282
|
-
spring: i,
|
|
283
|
-
tick: (s) => {
|
|
284
|
-
r.style.clipPath = `circle(${s * 100}% at 50% ${n}%)`;
|
|
285
|
-
}
|
|
286
|
-
};
|
|
287
|
-
},
|
|
288
|
-
out: (r) => {
|
|
289
|
-
const n = O(r);
|
|
290
|
-
return {
|
|
291
|
-
spring: i,
|
|
292
|
-
tick: (s) => {
|
|
293
|
-
r.style.clipPath = `circle(${s * 100}% at 50% ${n}%)`, r.style.zIndex = "100";
|
|
294
|
-
},
|
|
295
|
-
prepare: x
|
|
296
|
-
};
|
|
297
|
-
}
|
|
298
|
-
};
|
|
299
|
-
};
|
|
300
|
-
export {
|
|
301
|
-
D as fade,
|
|
302
|
-
H as hero,
|
|
303
|
-
I as pinterest,
|
|
304
|
-
F as ripple
|
|
305
|
-
};
|
|
1
|
+
export * from "@ssgoi/core/view-transitions";
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ssgoi/react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.1.0",
|
|
4
|
+
"description": "React bindings for SSGOI - Native app-like page transitions for React applications",
|
|
5
|
+
"private": false,
|
|
4
6
|
"type": "module",
|
|
5
7
|
"files": [
|
|
6
8
|
"dist",
|
|
7
|
-
"
|
|
9
|
+
"!dist/**/*.test.*",
|
|
10
|
+
"!dist/**/*.spec.*"
|
|
8
11
|
],
|
|
9
12
|
"main": "./dist/index.cjs",
|
|
10
13
|
"module": "./dist/index.js",
|
|
@@ -33,10 +36,25 @@
|
|
|
33
36
|
"import": "./dist/types.js",
|
|
34
37
|
"require": "./dist/types.cjs",
|
|
35
38
|
"default": "./dist/types.js"
|
|
39
|
+
},
|
|
40
|
+
"./presets": {
|
|
41
|
+
"types": "./dist/presets/index.d.ts",
|
|
42
|
+
"import": "./dist/presets/index.js",
|
|
43
|
+
"require": "./dist/presets/index.cjs",
|
|
44
|
+
"default": "./dist/presets/index.js"
|
|
36
45
|
}
|
|
37
46
|
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"dev": "vite build --watch",
|
|
49
|
+
"build": "tsc -b && vite build",
|
|
50
|
+
"watch": "vite build --watch",
|
|
51
|
+
"lint": "eslint .",
|
|
52
|
+
"preview": "vite preview",
|
|
53
|
+
"package": "vite build",
|
|
54
|
+
"prepare": "pnpm run build"
|
|
55
|
+
},
|
|
38
56
|
"dependencies": {
|
|
39
|
-
"@ssgoi/core": "
|
|
57
|
+
"@ssgoi/core": "workspace:*"
|
|
40
58
|
},
|
|
41
59
|
"peerDependencies": {
|
|
42
60
|
"react": "^19.0.0",
|
|
@@ -51,16 +69,34 @@
|
|
|
51
69
|
"eslint-plugin-react-hooks": "^5.2.0",
|
|
52
70
|
"eslint-plugin-react-refresh": "^0.4.20",
|
|
53
71
|
"globals": "^16.3.0",
|
|
72
|
+
"rollup-plugin-preserve-directives": "^0.4.0",
|
|
54
73
|
"typescript": "~5.8.3",
|
|
55
74
|
"typescript-eslint": "^8.35.1",
|
|
56
75
|
"vite": "^7.0.4",
|
|
57
76
|
"vite-plugin-dts": "^4.5.4"
|
|
58
77
|
},
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
78
|
+
"keywords": [
|
|
79
|
+
"react",
|
|
80
|
+
"page-transition",
|
|
81
|
+
"animation",
|
|
82
|
+
"ssgoi",
|
|
83
|
+
"spring-physics"
|
|
84
|
+
],
|
|
85
|
+
"author": "MeurSyphus <tmdeoans@snu.ac.kr>",
|
|
86
|
+
"license": "MIT",
|
|
87
|
+
"repository": {
|
|
88
|
+
"type": "git",
|
|
89
|
+
"url": "git+https://github.com/meursyphus/ssgoi.git",
|
|
90
|
+
"directory": "packages/react"
|
|
91
|
+
},
|
|
92
|
+
"homepage": "https://ssgoi.dev",
|
|
93
|
+
"bugs": {
|
|
94
|
+
"url": "https://github.com/meursyphus/ssgoi/issues"
|
|
95
|
+
},
|
|
96
|
+
"publishConfig": {
|
|
97
|
+
"access": "public"
|
|
98
|
+
},
|
|
99
|
+
"engines": {
|
|
100
|
+
"node": ">=18.0.0"
|
|
65
101
|
}
|
|
66
|
-
}
|
|
102
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
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.n=n;exports.r=r;
|