| 518 | let stillFrames = 0; |
| 519 | let hasMoved = false; |
| 520 | const waitForStill = () => { |
| 521 | const isStill = window.scrollY === lastY; |
| 522 | hasMoved = hasMoved || !isStill; |
| 523 | stillFrames = isStill ? stillFrames + 1 : 0; |
| 524 | lastY = window.scrollY; |
| 525 | if (stillFrames >= (hasMoved ? 6 : 20)) { |
| 526 | clearTimeout(timeoutRef.current); |
| 527 | blink(); |
| 528 | return; |
| 529 | } |
| 530 | frameRef.current = requestAnimationFrame(waitForStill); |
| 531 | }; |
| 532 | frameRef.current = requestAnimationFrame(waitForStill); |
| 533 | timeoutRef.current = setTimeout(blink, 1500); |
| 534 | }); |