anvaka / panzoom

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

Provide callback to cancel the zoom on double click #247

Open BrianWalters opened 3 years ago

BrianWalters commented 3 years ago

Just like beforeMouseDown, we need a way to cancel the double click zoom event depending on the event context. For example, if we have buttons overlayed on the panzoom area, a user double-clicking a button shouldn't initiate a zoom.

There is also no way I could see to disable the double click zoom entirely, if say someone created their own zoom in/out buttons, or maybe they want to implement some other function for a double click.

450Oucema commented 2 years ago

up please

RahulRaj97 commented 1 year ago

Hi @BrianWalters . I hope you are doing good. Were you able to figure out something. I am stuck in the same issue :)

catpea commented 10 months ago

For now, in your custom button/overlay add event.stopPropagation() like this:


function doTheThing(event) {
    hackTheGibson();
    event.stopPropagation();
    alert("event propagation halted.");
}

buttonOverlay.addEventListener("dblclick", doTheThing);

https://developer.mozilla.org/en-US/docs/Web/API/Event/stopPropagation

But, yes we need an option to disable double click Zoom, something like this doubleClickZoom: false

wihlke commented 3 days ago
panzoom(element, {
  zoomDoubleClickSpeed: 1,  // disables zoom on double click
});