@@ -482,19 +482,38 @@ export function Wires({ className }: { className?: string }) {
482
482
483
483
const ref = useRef < SVGSVGElement > ( null )
484
484
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
+
485
489
useEffect ( ( ) => {
486
490
const animate = document . querySelector (
487
491
"#paint_sr_pri_highlight_linear_671_9150 animate" ,
488
492
)
489
493
494
+ const onAnimationRepeat = ( ) => {
495
+ if ( shouldAvoidDoubleSpin . current ) return
496
+ inc ( )
497
+ }
498
+
490
499
if ( animate && animate instanceof SVGAnimateElement ) {
491
- animate . addEventListener ( "repeatEvent" , inc )
500
+ animate . addEventListener ( "repeatEvent" , onAnimationRepeat )
492
501
}
493
502
494
- return ( ) => animate ?. removeEventListener ( "repeatEvent" , inc )
503
+ return ( ) => animate ?. removeEventListener ( "repeatEvent" , onAnimationRepeat )
495
504
} , [ ] )
496
505
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
+ )
498
517
499
518
return (
500
519
< div className = { clsx ( className , "relative isolate" , styles . wires ) } >
@@ -547,7 +566,7 @@ export function Wires({ className }: { className?: string }) {
547
566
step === 2
548
567
? "[transform:rotateX(0deg)_translateY(0px)_translateZ(150px)]"
549
568
: step === 1
550
- ? "duration-0 [transform:rotateX(90deg)_translateY(60px)_translateZ(150px)]"
569
+ ? "! duration-0 [transform:rotateX(90deg)_translateY(60px)_translateZ(150px)]"
551
570
: "[transform:rotateX(-90deg)_translateY(-60px)_translateZ(150px)]" ,
552
571
) }
553
572
>
0 commit comments