daybrush / infinite-viewer

Infinite Viewer is Document Viewer Component with infinite scrolling.
https://daybrush.com/infinite-viewer/
MIT License
296 stars 33 forks source link

Question: Why is it scrolling with an "offset"? #47

Open bytasv opened 1 year ago

bytasv commented 1 year ago

Hey @daybrush - I know this isn't much, but maybe you have some ideas why this could be happening 👇

https://user-images.githubusercontent.com/437214/228061042-fed2b3c3-cac8-4ac1-91f5-672922688277.mp4

When I scroll it doesn't "stick" to the point where the cursor is and starts slowly moving away. This is my config:

    <InfiniteViewer
        ref={viewerRef}
        useWheelScroll
        wheelPinchKey='meta'
        useAutoZoom
        zoomRange={[CANVAS_VIEWER_MIN_SCALE, CANVAS_VIEWER_MAX_SCALE]}
        wheelScale={0.005}
        threshold={100}
        onPinch={(event) => {
          const { zoom: newZoom } = event

          viewerRef.current?.setZoom(newZoom)
        }}
      >
        {children}
      </InfiniteViewer>

I can see it's working in your demo, so it must be something on my end. I know it's tough without actual reproduction, but MAYBE you already see what might be causing that.

Thank you

daybrush commented 1 year ago

@bytasv

Um... I don't know.

But let's take a few guesses

If the container and viewport sizes are different from the stored values, the following problems may occur.

Try useResizeObserver. The size will automatically update.

bytasv commented 1 year ago

Thanks for guess! But useResizeObserver didn't help :( I know it's impossible to debug, but maybe someone will bump into similar issue and find a solution, or maybe I will eventually find out why its happening and can share that 😅