@@ -20,26 +20,26 @@ function drag(path, options) {
2020 Lib . clearThrottle ( ) ;
2121
2222 if ( options . type === 'touch' ) {
23- touchEvent ( 'touchstart' , path [ 0 ] [ 0 ] , path [ 0 ] [ 1 ] ) ;
23+ touchEvent ( 'touchstart' , path [ 0 ] [ 0 ] , path [ 0 ] [ 1 ] , options ) ;
2424
2525 path . slice ( 1 , len ) . forEach ( function ( pt ) {
2626 Lib . clearThrottle ( ) ;
27- touchEvent ( 'touchmove' , pt [ 0 ] , pt [ 1 ] ) ;
27+ touchEvent ( 'touchmove' , pt [ 0 ] , pt [ 1 ] , options ) ;
2828 } ) ;
2929
30- touchEvent ( 'touchend' , path [ len - 1 ] [ 0 ] , path [ len - 1 ] [ 1 ] ) ;
30+ touchEvent ( 'touchend' , path [ len - 1 ] [ 0 ] , path [ len - 1 ] [ 1 ] , options ) ;
3131 return ;
3232 }
3333
34- mouseEvent ( 'mousemove' , path [ 0 ] [ 0 ] , path [ 0 ] [ 1 ] ) ;
35- mouseEvent ( 'mousedown' , path [ 0 ] [ 0 ] , path [ 0 ] [ 1 ] ) ;
34+ mouseEvent ( 'mousemove' , path [ 0 ] [ 0 ] , path [ 0 ] [ 1 ] , options ) ;
35+ mouseEvent ( 'mousedown' , path [ 0 ] [ 0 ] , path [ 0 ] [ 1 ] , options ) ;
3636
3737 path . slice ( 1 , len ) . forEach ( function ( pt ) {
3838 Lib . clearThrottle ( ) ;
39- mouseEvent ( 'mousemove' , pt [ 0 ] , pt [ 1 ] ) ;
39+ mouseEvent ( 'mousemove' , pt [ 0 ] , pt [ 1 ] , options ) ;
4040 } ) ;
4141
42- mouseEvent ( 'mouseup' , path [ len - 1 ] [ 0 ] , path [ len - 1 ] [ 1 ] ) ;
42+ mouseEvent ( 'mouseup' , path [ len - 1 ] [ 0 ] , path [ len - 1 ] [ 1 ] , options ) ;
4343}
4444
4545function assertSelectionNodes ( cornerCnt , outlineCnt ) {
@@ -157,6 +157,43 @@ describe('Test select box and lasso in general:', function() {
157157
158158 drag ( selectPath ) ;
159159
160+ selectedPromise . then ( function ( ) {
161+ expect ( selectedCnt ) . toBe ( 1 , 'with the correct selected count' ) ;
162+ assertEventData ( selectedData . points , [ {
163+ curveNumber : 0 ,
164+ pointNumber : 0 ,
165+ x : 0.002 ,
166+ y : 16.25 ,
167+ id : 'id-0.002' ,
168+ customdata : 'customdata-16.25'
169+ } , {
170+ curveNumber : 0 ,
171+ pointNumber : 1 ,
172+ x : 0.004 ,
173+ y : 12.5 ,
174+ id : 'id-0.004' ,
175+ customdata : 'customdata-12.5'
176+ } ] , 'with the correct selected points (2)' ) ;
177+ assertRange ( selectedData . range , {
178+ x : [ 0.002000 , 0.0046236 ] ,
179+ y : [ 0.10209191961595454 , 24.512223978291406 ]
180+ } , 'with the correct selected range' ) ;
181+
182+ return doubleClick ( 250 , 200 ) ;
183+ } )
184+ . then ( deselectPromise )
185+ . then ( function ( ) {
186+ expect ( doubleClickData ) . toBe ( null , 'with the correct deselect data' ) ;
187+ } )
188+ . catch ( fail )
189+ . then ( done ) ;
190+ } ) ;
191+
192+ it ( 'should handle add/sub selection' , function ( done ) {
193+ resetEvents ( gd ) ;
194+
195+ drag ( selectPath ) ;
196+
160197 selectedPromise . then ( function ( ) {
161198 expect ( selectingCnt ) . toBe ( 1 , 'with the correct selecting count' ) ;
162199 assertEventData ( selectingData . points , [ {
@@ -178,8 +215,14 @@ describe('Test select box and lasso in general:', function() {
178215 x : [ 0.002000 , 0.0046236 ] ,
179216 y : [ 0.10209191961595454 , 24.512223978291406 ]
180217 } , 'with the correct selecting range' ) ;
181- expect ( selectedCnt ) . toBe ( 1 , 'with the correct selected count' ) ;
182- assertEventData ( selectedData . points , [ {
218+ } )
219+ . then ( function ( ) {
220+ // add selection
221+ drag ( [ [ 193 , 193 ] , [ 213 , 193 ] ] , { shiftKey : true } ) ;
222+ } )
223+ . then ( function ( ) {
224+ expect ( selectingCnt ) . toBe ( 2 , 'with the correct selecting count' ) ;
225+ assertEventData ( selectingData . points , [ {
183226 curveNumber : 0 ,
184227 pointNumber : 0 ,
185228 x : 0.002 ,
@@ -193,15 +236,37 @@ describe('Test select box and lasso in general:', function() {
193236 y : 12.5 ,
194237 id : 'id-0.004' ,
195238 customdata : 'customdata-12.5'
196- } ] , 'with the correct selected points (2)' ) ;
197- assertRange ( selectedData . range , {
198- x : [ 0.002000 , 0.0046236 ] ,
199- y : [ 0.10209191961595454 , 24.512223978291406 ]
200- } , 'with the correct selected range' ) ;
239+ } , {
240+ curveNumber : 0 ,
241+ pointNumber : 4 ,
242+ x : 0.013 ,
243+ y : 6.875 ,
244+ id : 'id-0.013' ,
245+ customdata : 'customdata-6.875'
246+ } ] , 'with the correct selecting points (1)' ) ;
247+ } )
248+ . then ( function ( ) {
249+ // sub selection
250+ drag ( [ [ 219 , 143 ] , [ 219 , 183 ] ] , { altKey : true } ) ;
251+ } ) . then ( function ( ) {
252+ assertEventData ( selectingData . points , [ {
253+ curveNumber : 0 ,
254+ pointNumber : 0 ,
255+ x : 0.002 ,
256+ y : 16.25 ,
257+ id : 'id-0.002' ,
258+ customdata : 'customdata-16.25'
259+ } , {
260+ curveNumber : 0 ,
261+ pointNumber : 1 ,
262+ x : 0.004 ,
263+ y : 12.5 ,
264+ id : 'id-0.004' ,
265+ customdata : 'customdata-12.5'
266+ } ] , 'with the correct selecting points (1)' ) ;
201267
202268 return doubleClick ( 250 , 200 ) ;
203269 } )
204- . then ( deselectPromise )
205270 . then ( function ( ) {
206271 expect ( doubleClickData ) . toBe ( null , 'with the correct deselect data' ) ;
207272 } )
0 commit comments