Skip to content

Commit

Permalink
useRef initial state
Browse files Browse the repository at this point in the history
  • Loading branch information
jaedb committed Jan 3, 2024
1 parent 35e1eb2 commit 6f6ad99
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/js/views/Modals/KioskMode.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ const LyricsScroller = ({
content = '',
percent = 0,
}) => {
const containerRef = useRef({});
const contentRef = useRef({});
const containerRef = useRef(null);
const contentRef = useRef(null);
const [autoScroll, setAutoScroll] = useState(true);
const onWheel = () => setAutoScroll(false);

useEffect(() => {
if (autoScroll) {
const scrollable = contentRef.current?.scrollHeight - containerRef.current.clientHeight;
containerRef.current.scrollTo(0, percent * scrollable)
const height = (contentRef.current?.scrollHeight - containerRef.current?.clientHeight) || 0;
containerRef.current.scrollTo(0, percent * height)
}
}, [percent]);

Expand Down

0 comments on commit 6f6ad99

Please sign in to comment.