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

'smooth: true' causes scrollTo to not work in Chrome, Edge, but works on Firefox

Open rjworks opened this issue 2 years ago • 10 comments

scroller.scrollTo(scrollRef.current[nextPage].props.name, {
                    duration: 800,
                    delay: 0,
                    smooth: true
                });

doesn't work in chrome and edge. works on firefox though.

When I remove smooth: true, it works on every browser. but it's ugly

rjworks avatar Jan 21 '22 20:01 rjworks

I have the same problem,when I use smooth,Cannot roll to specified position

Deadpool957 avatar Jan 24 '22 02:01 Deadpool957

Could you provide a plunkr/codepen to demonstrate the issue?

fisshy avatar Jan 24 '22 06:01 fisshy

it can not work

Deadpool957 avatar Jan 24 '22 08:01 Deadpool957

Roll inside the container,The height of the container is fixed, and the page will scroll automatically after loading

Deadpool957 avatar Jan 24 '22 08:01 Deadpool957

you can see this,https://codesandbox.io/s/container-forked-c3kse?file=/src/index.js

Deadpool957 avatar Jan 24 '22 08:01 Deadpool957

@rjworks Would it work if you wrote it like this instead.

scroller.scrollTo("scroll-to-element", {
      duration: 800,
      delay: 0,
      smooth: "easeInOutQuart",
      offset: offset
    });

fisshy avatar Feb 10 '22 06:02 fisshy

I had the same problem. But in my case I had a CSS property like this: html { scroll-behavior: smooth } When I removed this line it worked correctly.

Calisto184AC0 avatar Apr 23 '22 01:04 Calisto184AC0

Yes, it seems react-scroll doesn't work as expected when the scroll-behavior is set in the CSS. Since it is not always an option, to remove the scroll-behavior from the CSS (because it is quite handy) - is there a way to work around this using react-scroll?

saschadiercks avatar Aug 15 '22 14:08 saschadiercks

For me, scroll-behavior: smooth also caused the issue.

Maybe it's better to have this documented.

danny-dang avatar Jan 10 '23 16:01 danny-dang