react-scroll-to-bottom icon indicating copy to clipboard operation
react-scroll-to-bottom copied to clipboard

Scroll to bottom without the animation?

Open pranavmehta opened this issue 5 years ago • 6 comments

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?

pranavmehta avatar Aug 17 '20 14:08 pranavmehta

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?

vj-abishek avatar Sep 26 '20 09:09 vj-abishek

This will disable initial animation<ScrollToBottom initialScrollBehavior={'auto'}>

kisaragi99 avatar Apr 18 '21 10:04 kisaragi99

Anyone figure out how to make this work? I tried initialScrollBehavior, but it doesn't seem to work.

stevewillard avatar Mar 27 '23 14:03 stevewillard

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!

jeloi avatar Jun 26 '23 23:06 jeloi

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!

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

pitis avatar Aug 02 '23 00:08 pitis