Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save falcettijr/ce101132471c07fbcc879647eb1c21c2 to your computer and use it in GitHub Desktop.
Save falcettijr/ce101132471c07fbcc879647eb1c21c2 to your computer and use it in GitHub Desktop.
Como impedir que o scroll do chat suba automaticamente
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