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

Doesnt work with smooth-scroll

Open Hristo-Spasov opened this issue 2 years ago • 2 comments

I noticed that when smooth-scroll is added to an element the hook stops working. I couldn't find a way around.

Hristo-Spasov avatar Mar 21 '23 01:03 Hristo-Spasov

I have the same problem myself.

I had this issue, but I realised I only needed the smooth scroll when the user clicked one of the toggle arrows, so I have this handler:

    function handleScrollButton(scrollOffset) {
        scrollerContainer.current.classList.add('scroll-smooth')
        scrollerContainer.current.scrollLeft += scrollOffset
        scrollerContainer.current.classList.remove('scroll-smooth')
    }

It adds the smooth-scroll tailwind class, performs the scroll, then removes it again. Hacky, but it works.

JayBox325 avatar Jul 03 '23 10:07 JayBox325