anvaka / panzoom

Universal pan and zoom library (DOM, SVG, Custom)
https://anvaka.github.io/panzoom/demo/attach-via-script.html
MIT License
1.83k stars 293 forks source link

beforeMouseDown never triggered #150

Open cvharris opened 4 years ago

cvharris commented 4 years ago

I'm not sure why but the beforeMouseDown function is never called. I even tried adding it to the SVG Tiger JSFiddle and it was never fired.

Since I can't actually filter the mouse events for panning I can't customize its behavior in my app.

tommedema commented 4 years ago

Same here. This is breaking because it prevents me from disabling panning (I only need pinching).

jr-suraj commented 4 years ago

Same here. I used panzoom for vue draggable tree and it's mess when dragging elements and panning. Then I use beforeMouseDown and it doesn't call.

navneetsingh-cpu commented 4 years ago

Can you guys put a working example like Jsfiddle ?

jr-suraj commented 4 years ago

@dota2Pro like following code beforeZoom work well while press Alt key but beforeMouseDown not triggered `

beforeWheel: function(e) { // allow wheel-zoom only if altKey is down. Otherwise - ignore var shouldIgnore = !e.altKey; return shouldIgnore; }, beforeMouseDown: function(e) { var shouldIgnore = !e.altKey; return shouldIgnore; },`
jonanvc commented 4 years ago

i'm working in a similar way as @jr-suraj and I found out the way the event works:

In the very moment you push the mouse button the event is triggered, but when you keep moving it doesn't call the event once again.

If you want to use the event to stop dragging the panzoom element and start dragging other elements inside, you should check first in the event that the element is being clicked. This way I can move elements inside panzoom without moving the panzoom element.

davidbcoulson commented 2 years ago

I found that if I close the debugger window of the browser it works.