use-smooth-scroll icon indicating copy to clipboard operation
use-smooth-scroll copied to clipboard

scroll duration is hardcoded

Open jay-jlm opened this issue 5 years ago • 3 comments

I believe this would be a very useful feature since diferent scroll content/distances would (in certain scenarios) work best with custom scroll durations.

Let me know and I might submit a PR.

jay-jlm avatar Dec 19 '19 04:12 jay-jlm

It's not hardcoded - it only has a default value. You can call received scrollTo like this:

scrollTo(target, { duration: 1000 })

duration can even also be a function which receives computed distance as an argument - see this: https://github.com/Andarist/use-smooth-scroll/blob/6539b5ab4de753ecbc92fdcf74dc0c0a624b0b6f/src/index.js#L47-L52

Andarist avatar Dec 19 '19 09:12 Andarist

Thank you for your fast response. Overriding is not working for me in this example sandbox: https://codesandbox.io/s/focused-wozniak-i5dvu

jay-jlm avatar Dec 19 '19 15:12 jay-jlm

It's working fine - https://codesandbox.io/s/admiring-kalam-pxs9l .

You have not actually used implemented scrollToBottom which is using duration option, but rather was using inline handler which wasnt passing any additional options to scrollTo.

Andarist avatar Dec 20 '19 21:12 Andarist