@@ -25,8 +25,10 @@ function pointerK(kx, ky, {x, y, px, py, maxRadius = 40, channels, ...options} =
25
25
const facetState = faceted ? ( state . facetState ??= new Map ( ) ) : null ;
26
26
const tx = scales . fx ? scales . fx ( index . fx ) - dimensions . marginLeft : 0 ;
27
27
const ty = scales . fy ? scales . fy ( index . fy ) - dimensions . marginTop : 0 ;
28
- const { x : X0 , y : Y0 , x1 : X1 , y1 : Y1 , x2 : X2 , y2 : Y2 , px : X = X0 , py : Y = Y0 } = values ;
28
+ const { x : X , y : Y , x1 : X1 , y1 : Y1 , x2 : X2 , y2 : Y2 , px : PX , py : PY } = values ;
29
29
const [ cx , cy ] = applyFrameAnchor ( this , dimensions ) ;
30
+ const px = PX ? ( i ) => PX [ i ] : X2 ? ( i ) => ( X1 [ i ] + X2 [ i ] ) / 2 : X ? ( i ) => X [ i ] : ( ) => cx ;
31
+ const py = PY ? ( i ) => PY [ i ] : Y2 ? ( i ) => ( Y1 [ i ] + Y2 [ i ] ) / 2 : Y ? ( i ) => Y [ i ] : ( ) => cy ;
30
32
let i ; // currently focused index
31
33
let g ; // currently rendered mark
32
34
@@ -80,10 +82,8 @@ function pointerK(kx, ky, {x, y, px, py, maxRadius = 40, channels, ...options} =
80
82
let ii = null ;
81
83
let ri = maxRadius * maxRadius ;
82
84
for ( const j of index ) {
83
- const xj = X2 ? ( X1 [ j ] + X2 [ j ] ) / 2 : X ? X [ j ] : cx ;
84
- const yj = Y2 ? ( Y1 [ j ] + Y2 [ j ] ) / 2 : Y ? Y [ j ] : cy ;
85
- const dx = kx * ( xj - xp ) ;
86
- const dy = ky * ( yj - yp ) ;
85
+ const dx = kx * ( px ( j ) - xp ) ;
86
+ const dy = ky * ( py ( j ) - yp ) ;
87
87
const rj = dx * dx + dy * dy ;
88
88
if ( rj <= ri ) ( ii = j ) , ( ri = rj ) ;
89
89
}
0 commit comments