diff --git a/skills/motion-advanced/SKILL.md b/skills/motion-advanced/SKILL.md index a9d76ede..3b4116b7 100644 --- a/skills/motion-advanced/SKILL.md +++ b/skills/motion-advanced/SKILL.md @@ -365,14 +365,27 @@ export function CursorFollower() { "use client" import { motion } from "motion/react" -export function ShimmerSkeleton({ className }: { className?: string }) { - return ( -
- { + const run = () => + controls.start({ x: ["-100%", "100%"], transition: { repeat: Infinity, duration: 1.2, ease: "linear" } }) + const onVis = () => (document.visibilityState === "hidden" ? controls.stop() : run()) + run() + document.addEventListener("visibilitychange", onVis) + return () => document.removeEventListener("visibilitychange", onVis) + }, [controls]) + return ( +
+ + animate={controls} + /> +
+ ) + }
) }