d3 / d3-zoom

Pan and zoom SVG, HTML or Canvas using mouse or touch input.
https://d3js.org/d3-zoom
ISC License
507 stars 143 forks source link

Ignored attempt to cancel a touchmove event with cancelable=false #195

Closed MarkJPerry closed 4 years ago

MarkJPerry commented 4 years ago

When touching and dragging on a d3 graph which is handling touch events to provide "pinch to zoom" functionality the following errors appear in the browser console.

image

After some reading regarding the error the cause could possibly be found in:

https://github.com/d3/d3-zoom/blob/3c95789cd05cb04b99d568ddf4772d2cb58a8a0e/src/noevent.js#L8

where the event.preventDefault() is being used before checking if the event can be cancelled. Should be possible to fix by wrapping in a simple if statement?

Fil commented 4 years ago

event.cancelable && event.preventDefault() should fix it but I haven't been able to reproduce the issue.

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

Calling preventDefault() for a non-cancelable event has no effect.

and in my tests (https://observablehq.com/d/968b050af2fcec8e) I don't see anything (tested with Chrome, Firefox, Safari on MacOS).

Fil commented 4 years ago

Please send more information on how to reproduce this issue?