@@ -32,9 +32,6 @@ export class Lasso extends Mark {
3232 const margin = 5 ;
3333 const { ariaLabel, ariaDescription, ariaHidden, fill, fillOpacity, stroke, strokeWidth} = this ;
3434 const { marginLeft, width, marginRight, marginTop, height, marginBottom} = dimensions ;
35- if ( ! this . lasso ) this . lasso = [ ] ;
36- const polygons = [ ] ; // polygons for this facet
37- this . lasso . push ( { polygons, index} ) ;
3835
3936 const path = line ( ) . curve ( curveNatural ) ;
4037 const g = create ( "svg:g" )
@@ -47,10 +44,9 @@ export class Lasso extends Mark {
4744 . attr ( "fill" , "none" )
4845 . attr ( "cursor" , "cross" ) // TODO
4946 . attr ( "pointer-events" , "all" )
50- . attr ( "id" , "lasso" ) // TODO REMOVE
5147 . attr ( "fill-rule" , "evenodd" ) ;
5248
53- g . call ( lassoer ( polygons )
49+ g . call ( lassoer ( )
5450 . extent ( [ [ marginLeft - margin , marginTop - margin ] , [ width - marginRight + margin , height - marginBottom + margin ] ] )
5551 . on ( "start lasso end cancel" , ( polygons ) => {
5652 g . selectAll ( "path" )
@@ -111,12 +107,13 @@ function trackPointer(e, { start, move, out, end }) {
111107 start && start ( tracker ) ;
112108}
113109
114- function lassoer ( polygons = [ ] ) {
110+ function lassoer ( ) {
111+ const polygons = [ ] ;
115112 const dispatch = dispatcher ( "start" , "lasso" , "end" , "cancel" ) ;
116113 let extent ;
117114 const lasso = selection => {
118115 const node = selection . node ( ) ;
119- let polygon ;
116+ let currentPolygon ;
120117
121118 selection
122119 . on ( "touchmove" , e => e . preventDefault ( ) ) // prevent scrolling
@@ -131,12 +128,12 @@ function lassoer(polygons = []) {
131128 }
132129 trackPointer ( e , {
133130 start : p => {
134- polygon = [ constrainExtent ( p . point ) ] ;
135- polygons . push ( polygon ) ;
131+ currentPolygon = [ constrainExtent ( p . point ) ] ;
132+ polygons . push ( currentPolygon ) ;
136133 dispatch . call ( "start" , node , polygons ) ;
137134 } ,
138135 move : p => {
139- polygon . push ( constrainExtent ( p . point ) ) ;
136+ currentPolygon . push ( constrainExtent ( p . point ) ) ;
140137 dispatch . call ( "lasso" , node , polygons ) ;
141138 } ,
142139 end : ( ) => {
0 commit comments