react-scroll-to-bottom
react-scroll-to-bottom copied to clipboard
Scroll to bottom without the animation?
Is there a way to scroll to the bottom without the animation especially during the initial load?
I am using this in a chat-like an interface, and the animation gets extremely annoying when the conversation is long and it animates every time user switches the contact. I would like the scroll to be positioned at the bottom to begin with (without the animation) and then the usual scroll animation for future updates to the UI.
Is this possible?
I also need the same thing. I need to set the scroll bar initially to the bottom(without animation), and then to animate when something is changed. Is there any way to do that? @pranavmehta Did you found any solution?
This will disable initial animation<ScrollToBottom initialScrollBehavior={'auto'}>
Anyone figure out how to make this work? I tried initialScrollBehavior, but it doesn't seem to work.
hey y'all - sharing how I got this to work just now. It seems the initialScrollBehavior doesn't work as intended while the size of the container is changing - e.g while you're loading the content dynamically. I figured this out by turning on the debug mode.
What worked for me was to not render the component at all until my content loaded, and then on initial render it loads at the bottom as intended, without scrolling.
{messages?.length && (
<ScrollToBottom
initialScrollBehavior="auto"
{...scrollProps}
mode="bottom"
debug={true}
className="h-full x-dark:bg-gray-800"
>
<ScrollContent messages={messages} />
</ScrollToBottom>
)}
Hope this helps others!
hey y'all - sharing how I got this to work just now. It seems the
initialScrollBehaviordoesn't work as intended while the size of the container is changing - e.g while you're loading the content dynamically. I figured this out by turning on the debug mode. What worked for me was to not render the component at all until my content loaded, and then on initial render it loads at the bottom as intended, without scrolling.{messages?.length && ( <ScrollToBottom initialScrollBehavior="auto" {...scrollProps} mode="bottom" debug={true} className="h-full x-dark:bg-gray-800" > <ScrollContent messages={messages} /> </ScrollToBottom> )}Hope this helps others!
yup, just verified this, having the messages?.length as a verifier before works and it starts directly at the bottom, thank you very much, I've wasted hours with this