|
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 | 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 | 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) { |
|
0 commit comments