@@ -482,19 +482,38 @@ export function Wires({ className }: { className?: string }) {
482482
483483 const ref = useRef < SVGSVGElement > ( null )
484484
485+ // set to true by manual interaction: we skip the next animation end
486+ // if the animation finishes right after the user's click
487+ const shouldAvoidDoubleSpin = useRef ( false )
488+
485489 useEffect ( ( ) => {
486490 const animate = document . querySelector (
487491 "#paint_sr_pri_highlight_linear_671_9150 animate" ,
488492 )
489493
494+ const onAnimationRepeat = ( ) => {
495+ if ( shouldAvoidDoubleSpin . current ) return
496+ inc ( )
497+ }
498+
490499 if ( animate && animate instanceof SVGAnimateElement ) {
491- animate . addEventListener ( "repeatEvent" , inc )
500+ animate . addEventListener ( "repeatEvent" , onAnimationRepeat )
492501 }
493502
494- return ( ) => animate ?. removeEventListener ( "repeatEvent" , inc )
503+ return ( ) => animate ?. removeEventListener ( "repeatEvent" , onAnimationRepeat )
495504 } , [ ] )
496505
497- const onBackgroundClick = useMemo ( ( ) => throttle ( inc , 150 ) , [ ] )
506+ const onBackgroundClick = useMemo (
507+ ( ) =>
508+ throttle ( ( ) => {
509+ inc ( )
510+ shouldAvoidDoubleSpin . current = true
511+ setTimeout ( ( ) => {
512+ shouldAvoidDoubleSpin . current = false
513+ } , 750 )
514+ } , 500 ) ,
515+ [ ] ,
516+ )
498517
499518 return (
500519 < div className = { clsx ( className , "relative isolate" , styles . wires ) } >
@@ -547,7 +566,7 @@ export function Wires({ className }: { className?: string }) {
547566 step === 2
548567 ? "[transform:rotateX(0deg)_translateY(0px)_translateZ(150px)]"
549568 : step === 1
550- ? "duration-0 [transform:rotateX(90deg)_translateY(60px)_translateZ(150px)]"
569+ ? "! duration-0 [transform:rotateX(90deg)_translateY(60px)_translateZ(150px)]"
551570 : "[transform:rotateX(-90deg)_translateY(-60px)_translateZ(150px)]" ,
552571 ) }
553572 >
0 commit comments