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

Using componentDidMount to trigger scrollTo with dynamic created content

Open c0d3x opened this issue 6 years ago • 2 comments

I am using a Accordion type component that should scroll to the accordion body class minus the offset of accordion header.

Problem I have is when I trigger the accordion next click from the first accordion to the 2nd, the content is not matching the offset. It works if I set timout to 600ms instead of 300. But then you get a weird effect of content expanding and page scrolling after.

Is there a good way of fixing the expanding of content and scrolling at the same time?

    componentDidMount() {
        setTimeout(() => {
            scroller.scrollTo(this.props.scrollToId, {
                duration: 500,
                offset: -72,
                smooth: false,
                isDynamic: true // See no difference with this..
            });
        }, 300);
    }

c0d3x avatar Aug 06 '18 10:08 c0d3x

I have the same problem. But for me even timeouts do not help sometimes.

ShiiRochi avatar Nov 12 '19 21:11 ShiiRochi

I'm having the same problem with lazyload images that expand the content on scroll. isDynamic: true has no effect.

jirsbek avatar Nov 17 '19 11:11 jirsbek