@@ -21,6 +21,7 @@ function pointerK(kx, ky, {x, y, px, py, maxRadius = 40, channels, render, ...op
2121 // outermost render function because it will re-render dynamically in
2222 // response to pointer events.
2323 render : composeRender ( function ( index , scales , values , dimensions , context , next ) {
24+ context = { ...context , pointerSticky : false } ;
2425 const svg = context . ownerSVGElement ;
2526 const { data} = context . getMarkState ( this ) ;
2627
@@ -68,6 +69,7 @@ function pointerK(kx, ky, {x, y, px, py, maxRadius = 40, channels, render, ...op
6869
6970 let i ; // currently focused index
7071 let g ; // currently rendered mark
72+ let s ; // currently rendered stickiness
7173 let f ; // current animation frame
7274
7375 // When faceting, if more than one pointer would be visible, only show
@@ -97,8 +99,9 @@ function pointerK(kx, ky, {x, y, px, py, maxRadius = 40, channels, render, ...op
9799 }
98100
99101 function render ( ii ) {
100- if ( i === ii ) return ; // the tooltip hasn’t moved
102+ if ( i === ii && s === state . sticky ) return ; // the tooltip hasn’t moved
101103 i = ii ;
104+ s = context . pointerSticky = state . sticky ;
102105 const I = i == null ? [ ] : [ i ] ;
103106 if ( faceted ) ( I . fx = index . fx ) , ( I . fy = index . fy ) , ( I . fi = index . fi ) ;
104107 const r = next ( I , scales , values , dimensions , context ) ;
@@ -144,7 +147,7 @@ function pointerK(kx, ky, {x, y, px, py, maxRadius = 40, channels, render, ...op
144147 if ( i == null ) return ; // not pointing
145148 if ( state . sticky && state . roots . some ( ( r ) => r ?. contains ( event . target ) ) ) return ; // stay sticky
146149 if ( state . sticky ) ( state . sticky = false ) , state . renders . forEach ( ( r ) => r ( null ) ) ; // clear all pointers
147- else state . sticky = true ;
150+ else ( state . sticky = true ) , render ( i ) ;
148151 event . stopImmediatePropagation ( ) ; // suppress other pointers
149152 }
150153
0 commit comments