daybrush / infinite-viewer

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

Is there a way to use the dragging instead of scrolling to move around board/document. #26

Open xNarkon opened 2 years ago

xNarkon commented 2 years ago

Hi!

I looked inside and saw that you are using another of your libraries for this component called Gesto. You only react to the "touch" event, skip "mouse". And this causes a problem, I cannot do something like the Miro move tool. Sometimes, this movement is much more convenient than using a scroll.

I would like to enable document navigation by dragging the mouse on the board / document.

Would you consider introducing such an option? Otherwise, I will probably have to do my version via fork :( and I believe many people could use it!

ulissepress commented 2 years ago

same here, I would like to have a way to pan the canvas without using the scrollbars (as @xNarkon said in mobile you can pan using 2 fingers gesture). @daybrush any idea on how to get this ?

AustinHatem commented 2 years ago

would be great

ulissepress commented 2 years ago

In FIGMA, for example, you can pan clicking the mouse wheel and then moving the mouse...

daybrush commented 2 years ago

@ulissepress @AustinHatem @xNarkon

I'll add this feature soon. Thank you :)

daybrush commented 2 years ago

@ulissepress @AustinHatem @xNarkon

InfiniteViewer's new version is released. Update and Use useMouseDrag prop. (true / false)

ulissepress commented 1 year ago

@daybrush great! I tested the new property (useMouseDrag) and is working fine (you can pan the infinite viewer canvas with the mouse)... BUT there is a bug / side effect: when I'm dragging an in item in my diagram (via Moveable), the infinite viewer canvas is moving as well...

ulissepress commented 1 year ago

image

To be clear, for example when I drag the block 'CCC' the infinite viewer canvas is moving as well... This, instead, is not happening if I resize / rotate the element.

daybrush commented 1 year ago

@ulissepress

I'll add stopPropagation function to moveable.

ulissepress commented 1 year ago

I added the stopPropagation property to and set it to TRUE... but the issue is still there (when dragging an item, the infinite viewer is moving as well).

I anyway solved the issue using the SHIFT key to enable the infinite viewer useMouseDrag:

const shiftPressed = useKeyModifier('Shift')     // From @VueUse/core
...
 <VueInfiniteViewer 
            :useMouseDrag   = "shiftPressed"
            :useWheelScroll = "true"
            ... />

<Moveable 
           :stopPropagation = "true"
            ... />

Here you can see a live demo: https://ec7o9v.sse.codesandbox.io/

daybrush commented 1 year ago

@ulissepress

moveable's new version is released.

Use stopPropagation prop.

ulissepress commented 1 year ago

Hi @daybrush I dit the updates and this solved the issue.

One small suggestion: in fact clicking and dragging the infinite viewer is ok unless.... you want to use the Selecto package. In this case clicking and dragging in the canvas area is used to select items.

My suggestion is to use a key modifier to enable the click-canvas to pan, like shift or better ctrl key, like is already to activate infinite viewer zoom using mouse wheel together with ctrl key (useWheelScroll = "true").

<VueInfiniteViewer 
            :useMouseDrag = "true"
            mouseDragKeyModifier ="ctrl".  // default, can be also 'shift' or 'alt'
            ... />
daybrush commented 1 year ago

@ulissepress

sorry. As much as possible, I try not to control the key internally. It is recommended to control through a hook and reactive state using a key controller as shown below.

https://codesandbox.io/s/laughing-danny-p8xd4s

d2461379109 commented 1 year ago

此 Can you turn off the sliding acceleration? useMouseDrag

d2461379109 commented 1 year ago

@daybrush

daybrush commented 1 year ago

@d2461379109

okay. i"ll add it soon.