Skip to content

Commit 962dbfe

Browse files
authored
fix(AnnotationPoint): Do not propagate mouse/touch move/leave events to TooltipContext after switching from pointer events. Fixes #598 (#602)
1 parent 48091b9 commit 962dbfe

3 files changed

Lines changed: 26 additions & 10 deletions

File tree

.changeset/clean-nights-jog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'layerchart': patch
3+
---
4+
5+
fix(AnnotationPoint): Do not propagate mouse/touch move/leave events to TooltipContext after switching from pointer events. Fixes #598

packages/layerchart/src/lib/components/AnnotationPoint.svelte

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,23 +88,30 @@
8888
? 'start'
8989
: 'middle',
9090
});
91-
</script>
9291
93-
<Circle
94-
cx={point.x}
95-
cy={point.y}
96-
{r}
97-
onpointermove={(e) => {
92+
function onPointerMove(e: PointerEvent | MouseEvent | TouchEvent) {
9893
if (details) {
9994
e.stopPropagation();
10095
ctx.tooltip.show(e, { annotation: { label, details } });
10196
}
102-
}}
103-
onpointerleave={() => {
97+
}
98+
99+
function onPointerLeave(e: PointerEvent | MouseEvent | TouchEvent) {
104100
if (details) {
101+
e.stopPropagation();
105102
ctx.tooltip.hide();
106103
}
107-
}}
104+
}
105+
</script>
106+
107+
<Circle
108+
cx={point.x}
109+
cy={point.y}
110+
{r}
111+
onmousemove={onPointerMove}
112+
ontouchmove={onPointerMove}
113+
onmouseleave={onPointerLeave}
114+
ontouchend={onPointerLeave}
108115
{...props?.circle}
109116
class={cls('stroke-surface-100', props?.circle?.class)}
110117
/>

packages/layerchart/src/lib/components/tooltip/TooltipContext.svelte

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222
y: number;
2323
data: T | null;
2424
payload: TooltipPayload[];
25-
show(e: PointerEvent, tooltipData?: any, payload?: TooltipPayload): void;
25+
show(
26+
e: PointerEvent | MouseEvent | TouchEvent,
27+
tooltipData?: any,
28+
payload?: TooltipPayload
29+
): void;
2630
hide(e?: PointerEvent): void;
2731
mode: TooltipMode;
2832
isHoveringTooltipArea: boolean;

0 commit comments

Comments
 (0)