11'use client' ;
22
3- import { motion } from 'framer-motion' ;
3+ import { motion , useReducedMotion } from 'framer-motion' ;
44import { useEffect , useState } from 'react' ;
55
66// Generates an array of particles
@@ -41,7 +41,7 @@ interface Particle {
4141export default function BrandParticles ( ) {
4242 const [ particles ] = useState < Particle [ ] > ( ( ) => generateParticles ( 40 ) ) ;
4343 const [ mounted , setMounted ] = useState ( false ) ;
44-
44+ const shouldReduceMotion = useReducedMotion ( ) ;
4545 useEffect ( ( ) => {
4646 // eslint-disable-next-line react-hooks/set-state-in-effect
4747 setMounted ( true ) ;
@@ -66,17 +66,25 @@ export default function BrandParticles() {
6666 boxShadow : `0 0 ${ particle . size * 2 } px ${ particle . color } ` ,
6767 borderRadius : particle . borderRadius ,
6868 } }
69- animate = { {
70- y : [ 0 , - 150 , 150 , 0 ] , // Float up and around
71- x : [ 0 , particle . xAnimStart , particle . xAnimEnd , 0 ] ,
72- rotate : [ 0 , 360 * particle . rotateDirection ] ,
73- } }
74- transition = { {
75- duration : particle . duration ,
76- delay : particle . delay ,
77- repeat : Infinity ,
78- ease : 'linear' ,
79- } }
69+ animate = {
70+ shouldReduceMotion
71+ ? { }
72+ : {
73+ y : [ 0 , - 150 , 150 , 0 ] ,
74+ x : [ 0 , particle . xAnimStart , particle . xAnimEnd , 0 ] ,
75+ rotate : [ 0 , 360 * particle . rotateDirection ] ,
76+ }
77+ }
78+ transition = {
79+ shouldReduceMotion
80+ ? { }
81+ : {
82+ duration : particle . duration ,
83+ delay : particle . delay ,
84+ repeat : Infinity ,
85+ ease : 'linear' ,
86+ }
87+ }
8088 />
8189 ) ) }
8290 </ div >
0 commit comments