-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgrid.js
97 lines (95 loc) · 2.52 KB
/
grid.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import {
j as y
} from "./jsx-runtime.70483414.js";
import {
r
} from "./index.7c191284.js";
import {
b as m,
a as p
} from "./use-transform.68353e3f.js";
import {
M,
a as g,
b as k,
f as l,
c as x,
u as S,
m as E
} from "./motion.08011aae.js";
import {
u as C
} from "./use-motion-template.33d434db.js";
import "./index.38f30a65.js";
function b(e, o = {}) {
const {
isStatic: u
} = r.useContext(M), s = r.useRef(null), t = m(g(e) ? e.get() : e), i = () => {
s.current && s.current.stop()
};
return r.useInsertionEffect(() => t.attach((n, a) => {
if (u) return a(n);
if (i(), s.current = k({
keyframes: [t.get(), n],
velocity: t.getVelocity(),
type: "spring",
restDelta: .001,
restSpeed: .01,
...o,
onUpdate: a
}), !l.isProcessing) {
const c = performance.now() - l.timestamp;
c < 30 && (s.current.time = x(c))
}
return t.get()
}, i), [JSON.stringify(o)]), S(() => {
if (g(e)) return e.on("change", n => t.set(parseFloat(n)))
}, [t]), t
}
const X = {
src: "/_astro/future-grid.a0cd4189.webp",
width: 2880,
height: 1619,
format: "webp"
},
w = {
damping: 17.5,
mass: .5,
stiffness: 150
};
function T() {
console.log("yeah");
const e = m(0),
o = m(0),
u = p(e, [-1, 1], [15, -15]),
s = p(o, [-1, 1], [15, -15]),
t = b(u, w),
i = b(s, w),
n = r.useCallback(({
clientX: a,
clientY: c
}) => {
const d = window.innerWidth / 2,
f = window.innerHeight / 2,
h = (a - d) / d,
v = (c - f) / f;
e.set(h), o.set(v)
}, [e, o]);
console.log(t);
console.log(i);
return r.useEffect(() => (window.addEventListener("mousemove", n), () => {
window.removeEventListener("mousemove", n)
}), [n]), y.jsx(E.div, {
"aria-hidden": !0,
className: "pointer-events-none absolute inset-0 -z-50 overflow-hidden bg-primary bg-[size:103%_103%] bg-no-repeat object-fill",
style: {
backgroundImage: `url(${X.src})`,
backgroundPosition: C `calc(50% + ${t}px) calc(50% + ${i}px)`
}
})
}
T();
export {
T as
default
};