-
-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathexamples.js
More file actions
23 lines (20 loc) · 671 Bytes
/
Copy pathexamples.js
File metadata and controls
23 lines (20 loc) · 671 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import React from "react";
import { useSpring, animated } from "react-spring";
import { useDrag } from "react-use-gesture";
import * as styles from "./styles.module.css";
export function EasterDiv({ children }) {
const [{ x, y, live }, set] = useSpring(() => ({ x: 0, y: 0, live: false }));
const bind = useDrag(({ down, movement: [mx, my] }) => {
document.body.classList.toggle("dragged", down);
set({ x: down ? mx : 0, y: down ? my : 0, live: down });
});
return (
<animated.span
className={styles?.easter}
{...bind()}
style={{ x, y, zIndex: live.to((a) => (a ? 10000 : 0)) }}
>
{children}
</animated.span>
);
}