svelteplot 0.4.2-pr-186.0 → 0.4.2-pr-186.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -59,7 +59,12 @@ export function addEventHandlers(node, { options, datum, getPlotState }) {
59
59
  const { scales, body, options } = getPlotState();
60
60
  if (origEvent instanceof MouseEvent || origEvent instanceof PointerEvent) {
61
61
  let facetEl = origEvent.target;
62
- while (facetEl && !facetEl.classList.contains('facet')) {
62
+ while (facetEl &&
63
+ !facetEl.classList.contains('facet') &&
64
+ facetEl.parentElement) {
65
+ // ensure that parentElement is SVGElement
66
+ if (!(facetEl.parentElement instanceof SVGElement))
67
+ break;
63
68
  facetEl = facetEl.parentElement;
64
69
  }
65
70
  const facetRect = (facetEl?.firstChild ?? body).getBoundingClientRect();
@@ -99,7 +104,7 @@ function invertScale(scale, position) {
99
104
  const domain = scale.fn.domain();
100
105
  const eachBand = scale.fn.step();
101
106
  const extent = range[1] - range[0];
102
- const posInRange = ((position - range[0]) / extent) * Math.abs(extent);
107
+ const posInRange = (position - range[0]) * Math.sign(extent);
103
108
  const index = Math.floor(posInRange / eachBand);
104
109
  return domain[index];
105
110
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelteplot",
3
- "version": "0.4.2-pr-186.0",
3
+ "version": "0.4.2-pr-186.2",
4
4
  "license": "ISC",
5
5
  "author": {
6
6
  "name": "Gregor Aisch",