Skip to content

Commit ee45883

Browse files
Filmbostock
authored andcommitted
Return the usual euclidian distance to determine the winner across facets, not the squashed distance.
fixes #1776
1 parent 99397d9 commit ee45883

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/interactions/pointer.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ function pointerK(kx, ky, {x, y, px, py, maxRadius = 40, channels, render, ...op
130130
return r;
131131
}
132132

133+
// Select the closest point to the mouse in the current facet; for
134+
// pointerX or pointerY, the orthogonal component of the distance is
135+
// squashed, selecting primarily on the dominant dimension. Return the
136+
// usual euclidian distance to determine the winner across facets.
133137
function pointermove(event) {
134138
if (state.sticky || (event.pointerType === "mouse" && event.buttons === 1)) return; // dragging
135139
let [xp, yp] = pointof(event);
@@ -142,7 +146,7 @@ function pointerK(kx, ky, {x, y, px, py, maxRadius = 40, channels, render, ...op
142146
const rj = dx * dx + dy * dy;
143147
if (rj <= ri) (ii = j), (ri = rj);
144148
}
145-
update(ii, ri);
149+
update(ii, Math.hypot(px(ii) - xp, py(ii) - yp));
146150
}
147151

148152
function pointerdown(event) {

0 commit comments

Comments
 (0)