Created
December 6, 2023 19:36
-
-
Save falcettijr/ce101132471c07fbcc879647eb1c21c2 to your computer and use it in GitHub Desktop.
Como impedir que o scroll do chat suba automaticamente
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
useEffect(() => { | |
const chatBody = chatBodyRef.current; | |
if (chatBody) { | |
const isUserScrollingUp = chatBody.scrollHeight - chatBody.scrollTop > chatBody.clientHeight + 10; | |
if (!isUserScrollingUp) { | |
chatBody.scrollTop = chatBody.scrollHeight; | |
} | |
} | |
}, [messages]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment