Closed qrest closed 6 months ago
You’re supposed to use d3.pointers for this instead of using d3.pointer. It’s to encourage you to think about multitouch rather than assuming that the first touch is equivalent to a pointer.
The documentation for pointer()
states "event can be a MouseEvent, a PointerEvent, a Touch, or a custom event holding a UIEvent as event.sourceEvent."
So either it's a bug in the code or the documentation is wrong.
No, the docs are right. A Touch and a TouchEvent are two different things. Given a TouchEvent event
you can pass a Touch event.touches[0]
to d3.pointer.
I see, thank you for clarifying
When calling
pointer()
on a touch event it fails with following error message: SVGPoint.x setter: Value being assigned is not a finite floating-point value. This is becauseclientX/Y
is only present in the respective touch object.This PR detects if a touch event is present and handles it appropriately.