layerchart 2.0.0-next.21 → 2.0.0-next.23

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.
@@ -319,7 +319,7 @@
319
319
  _range.width < RESET_THRESHOLD ||
320
320
  _range.height < RESET_THRESHOLD
321
321
  ) {
322
- // Clicked on frame, or pointer delta was <1
322
+ // Clicked on frame, or pointer delta was less than threshold (default: 1px)
323
323
  if (ignoreResetClick) {
324
324
  logger.debug('ignoring frame click reset');
325
325
  } else {
@@ -175,7 +175,7 @@
175
175
  y2: max(ctx.yRange) as unknown as number,
176
176
  })),
177
177
  ];
178
- } else if (xCoord) {
178
+ } else if (xCoord != null) {
179
179
  tmpLines = [
180
180
  ...tmpLines,
181
181
  {
@@ -201,7 +201,7 @@
201
201
  y2: yItem + yOffset,
202
202
  })),
203
203
  ];
204
- } else if (yCoord) {
204
+ } else if (yCoord != null) {
205
205
  tmpLines = [
206
206
  ...tmpLines,
207
207
  {
@@ -55,7 +55,7 @@
55
55
  <script lang="ts">
56
56
  import { min } from 'd3-array';
57
57
  import { Delaunay } from 'd3-delaunay';
58
- // @ts-expect-error
58
+ // @ts-expect-error - no types available
59
59
  import { geoVoronoi } from 'd3-geo-voronoi';
60
60
  import { curveLinearClosed } from 'd3-shape';
61
61
  import { cls } from '@layerstack/tailwind';
@@ -270,7 +270,7 @@
270
270
  }
271
271
  }
272
272
 
273
- function showTooltip(e: PointerEvent, tooltipData?: any) {
273
+ function showTooltip(e: PointerEvent | MouseEvent | TouchEvent, tooltipData?: any) {
274
274
  // Cancel hiding tooltip if from previous event loop
275
275
  if (hideTimeoutId) {
276
276
  clearTimeout(hideTimeoutId);
@@ -511,6 +511,24 @@
511
511
  const triggerPointerEvents = $derived(
512
512
  ['bisect-x', 'bisect-y', 'bisect-band', 'quadtree'].includes(mode)
513
513
  );
514
+
515
+ function onPointerEnter(e: PointerEvent | MouseEvent | TouchEvent) {
516
+ isHoveringTooltipArea = true;
517
+ if (triggerPointerEvents) {
518
+ showTooltip(e);
519
+ }
520
+ }
521
+
522
+ function onPointerMove(e: PointerEvent | MouseEvent | TouchEvent) {
523
+ if (triggerPointerEvents) {
524
+ showTooltip(e);
525
+ }
526
+ }
527
+
528
+ function onPointerLeave(e: PointerEvent | MouseEvent | TouchEvent) {
529
+ isHoveringTooltipArea = false;
530
+ hideTooltip();
531
+ }
514
532
  </script>
515
533
 
516
534
  <!-- svelte-ignore a11y_no_static_element_interactions -->
@@ -521,25 +539,15 @@
521
539
  style:height="{ctx.height}px"
522
540
  class={cls(
523
541
  layerClass('tooltip-context'),
524
- 'absolute touch-none',
542
+ 'absolute',
525
543
  debug && triggerPointerEvents && 'bg-danger/10 outline outline-danger'
526
544
  )}
527
- onpointerenter={(e) => {
528
- isHoveringTooltipArea = true;
529
- if (triggerPointerEvents) {
530
- showTooltip(e);
531
- }
532
- }}
533
- onpointermove={(e) => {
534
- if (triggerPointerEvents) {
535
- showTooltip(e);
536
- }
537
- }}
538
- onpointerleave={(e) => {
539
- isHoveringTooltipArea = false;
540
-
541
- hideTooltip();
542
- }}
545
+ onmouseenter={onPointerEnter}
546
+ ontouchstart={onPointerEnter}
547
+ onmousemove={onPointerMove}
548
+ ontouchmove={onPointerMove}
549
+ onmouseleave={onPointerLeave}
550
+ ontouchend={onPointerLeave}
543
551
  onclick={(e) => {
544
552
  // Ignore clicks without data (triggered from Legend clicks, for example)
545
553
  if (triggerPointerEvents && tooltipContext.data != null) {
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "author": "Sean Lynch <techniq35@gmail.com>",
5
5
  "license": "MIT",
6
6
  "repository": "techniq/layerchart",
7
- "version": "2.0.0-next.21",
7
+ "version": "2.0.0-next.23",
8
8
  "devDependencies": {
9
9
  "@changesets/cli": "^2.29.4",
10
10
  "@iconify-json/lucide": "^1.2.48",