| 526 | let stillFrames = 0; |
| 527 | let hasMoved = false; |
| 528 | const waitForStill = () => { |
| 529 | const isStill = window.scrollY === lastY; |
| 530 | hasMoved = hasMoved || !isStill; |
| 531 | stillFrames = isStill ? stillFrames + 1 : 0; |
| 532 | lastY = window.scrollY; |
| 533 | if (stillFrames >= (hasMoved ? 6 : 20)) { |
| 534 | clearTimeout(timeoutRef.current); |
| 535 | blink(); |
| 536 | return; |
| 537 | } |
| 538 | frameRef.current = requestAnimationFrame(waitForStill); |
| 539 | }; |
| 540 | frameRef.current = requestAnimationFrame(waitForStill); |
| 541 | timeoutRef.current = setTimeout(blink, 1500); |
| 542 | }); |