Skip to content
This repository has been archived by the owner on Nov 18, 2024. It is now read-only.

Commit

Permalink
fix: fix infinity scroll trigger (#558)
Browse files Browse the repository at this point in the history
  • Loading branch information
re-taro authored Nov 11, 2024
1 parent 6a259ab commit a582164
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/routes/endroll/features/Epilogue/Epilogue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@ export function Epilogue({ targetRef }: Props): ReactNode {
function EpilogueText({ targetRef }: Props): ReactNode {
const [index, setIndex] = useState(0);
const loopRef = useRef<number>();
const scrolledRef = useRef(false);
const { ref } = useScramble({
chance: 0.8,
onAnimationEnd: () => {
clearInterval(loopRef.current);
loopRef.current = window.setTimeout(() => {
setIndex(index => (index < EPILOGUES.length - 1 ? index + 1 : 0));
if (index === 2) {
if (index === 2 && !scrolledRef.current) {
targetRef.current?.scrollIntoView({ behavior: "smooth" });
scrolledRef.current = true;
}
}, 2000);
},
Expand Down

0 comments on commit a582164

Please sign in to comment.