d3 / d3-selection

Transform the DOM by selecting elements and joining to data.
https://d3js.org/d3-selection
ISC License
557 stars 292 forks source link

Firefox error when calling d3.pointer inside of 'zoom' event handler #319

Open Fil opened 2 months ago

Fil commented 2 months ago

Discussed in https://github.com/d3/d3/discussions/3907

Originally posted by @tsairinius August 29, 2024 In the following example, I am calling d3.pointer inside of a 'zoom' event handler. The zoom behavior is being applied to an SVG element. When I call the zoom behavior's `scaleTo` method, the following error occurs in Firefox (Chrome and Edge seem to work fine): "TypeError: SVGPoint.x setter: Value being assigned is not a finite floating-point value." I've also tried replacing `scaleTo` with `scaleBy` and `transform`, but the same error pops up. See example here: https://jsfiddle.net/nLt523mj/
Fil commented 2 months ago

It happens here https://github.com/d3/d3-selection/blob/d8ea8005f87ca72496d748a91ab6e0ccbe1a2011/src/pointer.js#L10

the pointer receives an event that has no clientX property, which triggers the error.