Skip to content

Commit b070b2b

Browse files
committed
Update useAnimation.stories.tsx
1 parent c426770 commit b070b2b

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

stories/hooks/useAnimation.stories.tsx

+12-1
Original file line numberDiff line numberDiff line change
@@ -472,8 +472,9 @@ export const Path: StoryObj = {
472472

473473
export const ThreeDimentional: StoryObj = {
474474
render: () => {
475+
const [pos, setPos] = useState({ x: 1, y: 1 });
475476
const animate = useAnimation(
476-
{ transform: "rotate3d(1, 1, 1, 360deg)" },
477+
{ transform: `rotate3d(${pos.y / 100}, ${pos.x / 100}, 0, 360deg)` },
477478
{
478479
duration: 1000,
479480
iterations: Infinity,
@@ -482,6 +483,16 @@ export const ThreeDimentional: StoryObj = {
482483

483484
useEffect(() => {
484485
animate.play();
486+
}, [pos]);
487+
488+
useEffect(() => {
489+
const onPointerMove = (e: PointerEvent) => {
490+
setPos({ x: e.clientX, y: e.clientY });
491+
};
492+
window.addEventListener("pointermove", onPointerMove);
493+
return () => {
494+
window.removeEventListener("pointermove", onPointerMove);
495+
};
485496
}, []);
486497

487498
return (

0 commit comments

Comments
 (0)