| 533 | let stillFrames = 0; |
| 534 | let hasMoved = false; |
| 535 | const waitForStill = () => { |
| 536 | const isStill = window.scrollY === lastY; |
| 537 | hasMoved = hasMoved || !isStill; |
| 538 | stillFrames = isStill ? stillFrames + 1 : 0; |
| 539 | lastY = window.scrollY; |
| 540 | if (stillFrames >= (hasMoved ? 6 : 20)) { |
| 541 | clearTimeout(timeoutRef.current); |
| 542 | blink(); |
| 543 | return; |
| 544 | } |
| 545 | frameRef.current = requestAnimationFrame(waitForStill); |
| 546 | }; |
| 547 | frameRef.current = requestAnimationFrame(waitForStill); |
| 548 | timeoutRef.current = setTimeout(blink, 1500); |
| 549 | }); |