@@ -132,11 +132,17 @@ function pointerK(kx, ky, {x, y, px, py, maxRadius = 40, channels, render, ...op
132
132
133
133
// Select the closest point to the mouse in the current facet; for
134
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.
135
+ // squashed, selecting primarily on the dominant dimension. Across facets,
136
+ // use the euclidian distance to determine the winner. The current facet’s
137
+ // surface includes the frame, margins and pointer radius.
137
138
function pointermove ( event ) {
138
139
if ( state . sticky || ( event . pointerType === "mouse" && event . buttons === 1 ) ) return ; // dragging
139
140
let [ xp , yp ] = pointof ( event ) ;
141
+ const hw = dimensions . width / 2 ;
142
+ const hh = dimensions . height / 2 ;
143
+ const offFrame =
144
+ ( kx !== 1 && fx && Math . abs ( xp - ( fx ( index . fx ) + hw ) ) > hw + maxRadius ) ||
145
+ ( ky !== 1 && fy && Math . abs ( yp - ( fy ( index . fy ) + hh ) ) > hh + maxRadius ) ;
140
146
( xp -= tx ) , ( yp -= ty ) ; // correct for facets and band scales
141
147
let ii = null ;
142
148
let ri = maxRadius * maxRadius ;
@@ -146,7 +152,13 @@ function pointerK(kx, ky, {x, y, px, py, maxRadius = 40, channels, render, ...op
146
152
const rj = dx * dx + dy * dy ;
147
153
if ( rj <= ri ) ( ii = j ) , ( ri = rj ) ;
148
154
}
149
- update ( ii , ii != null && Math . hypot ( px ( ii ) - xp , py ( ii ) - yp ) ) ;
155
+ if ( ii != null ) {
156
+ const dx = px ( ii ) - xp ;
157
+ const dy = py ( ii ) - yp ;
158
+ ri = dx * dx + dy * dy ;
159
+ if ( offFrame && ri > maxRadius * maxRadius ) ii = null ;
160
+ }
161
+ update ( ii , ri ) ;
150
162
}
151
163
152
164
function pointerdown ( event ) {
0 commit comments