question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

scrollToBottom not scrolling to bottom

See original GitHub issue

What I need Auto scroll through a table that is in a fixed container

What i’ve done I have a fixed height div (700px) containing a table of data. The height of the table is greater than the container and thus is scrollable (as planned). I wanted to auto scroll through the table contents using animateScroll.scrollToBottom(). This is not working 100%. The content of the div is scrolling but only for 700px of the content (so around 1/3). This is obviously something to do with the fixed height of the table but that cannot be changed>

Heres what I have


class LeaderBoard extends React.Component {
    componentDidMount = () => {
        scroll.scrollToBottom({
            containerId: "scrollContainer",
            duration: 3000,
            delay: 2000,
            smooth: "linear"
        });
    };
    render() {
        return (
            <Panel ref={this.tableContainer} id="scrollContainer">
                <Table>
                    <tbody>
                        {this.renderTableHeaders()} // generates th's
                        {this.renderTableRows()} / / generates tr's
                    </tbody>
                </Table>
            </Panel>
        );
    }
}

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
AlGantoricommented, Feb 7, 2022

If my guess is correct don’t use the garbage scrolling methods from your framework here react, I have the same problem with framework ionic, instead use standard .scrollIntoView() it works nicely…

I set up two dummy hidden divs, top and bottom around my “content” like so

<div id="QV_Top">TOP</div> 
... your actual content here
<div id="QV_Bottom">BOTTOM</div>

then fixed my scroll helper methods like so: image

finally the actual scroll to id follows: image

1reaction
darrenkleincommented, Jun 9, 2020

EDIT: I don’t believe that this fix illustrates the correct use of the scrollToBottom() function, so I would advise ignoring what I’ve written here. Leaving it for posterity, though…

I experienced this issue as well - in my case, I was able to resolve it by wrapping the call to scrollToBottom in a setTimeout with the second argument set to 0. Not sure why that helps, but I’ve bumped into this sort of thing before in other situations… woo front end!

import React from 'react'
import { connect } from 'react-redux'
import { animateScroll } from 'react-scroll'
import BroadcastMessage from './broadcast-message'
import { mapStateToProps } from 'js/redux/util'
import styles from 'styles/app'

const scrollToBottom = () => {
	animateScroll.scrollToBottom({
		containerId: 'broadcast_message_list_container'
	})
}

const BroadcastMessagesList = ({ state }) => {
	if (state.foo.length) {
		setTimeout(() => {
			scrollToBottom()
		}, 0)
	}

	return (
		<div className={styles.list_container}>
			<ul id='broadcast_message_list_container'>
				{
					state.foo.map((message) => {
						return (
							<li key={messge.id}>
								<BroadcastMessage message={message} />
							</li>
						)
					})
				}
			</ul>
		</div>
	)
}

export default connect(mapStateToProps)(BroadcastMessagesList)
Read more comments on GitHub >

github_iconTop Results From Across the Web

ionic3 - Content Scroll to Bottom Not Working - Stack Overflow
The problem is that the scrollToBottom() code may run before the DOM is completely updated. Several solutions ...
Read more >
scrollTo | Cypress Documentation
scrollTo('bottom ') // Scroll 'sidebar' to its bottom. Incorrect Usage. cy.title().scrollTo('My App') // Errors, 'title' does not yield DOM element ...
Read more >
Scroll to Bottom of List in iOS 16… | Apple Developer Forums
I am using ScrollView instead of List inside ScrollViewReader and the scrolling does not work since iOS16.0. In 16.0, it seems to work...
Read more >
Form will not scroll to bottom - Power Platform Community
Form will not scroll to bottom. ‎02-12-2020 08:19 AM. From SharePoint Online, I have selected "Customize Form" and created my form in PowerApps, ......
Read more >
Automatic Scroll-To-Bottom in Flutter | smarx.com
Learn how to scroll to the bottom of a Flutter ListView when new items are added.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found