@@ -20,26 +20,26 @@ function drag(path, options) {
20
20
Lib . clearThrottle ( ) ;
21
21
22
22
if ( options . type === 'touch' ) {
23
- touchEvent ( 'touchstart' , path [ 0 ] [ 0 ] , path [ 0 ] [ 1 ] ) ;
23
+ touchEvent ( 'touchstart' , path [ 0 ] [ 0 ] , path [ 0 ] [ 1 ] , options ) ;
24
24
25
25
path . slice ( 1 , len ) . forEach ( function ( pt ) {
26
26
Lib . clearThrottle ( ) ;
27
- touchEvent ( 'touchmove' , pt [ 0 ] , pt [ 1 ] ) ;
27
+ touchEvent ( 'touchmove' , pt [ 0 ] , pt [ 1 ] , options ) ;
28
28
} ) ;
29
29
30
- touchEvent ( 'touchend' , path [ len - 1 ] [ 0 ] , path [ len - 1 ] [ 1 ] ) ;
30
+ touchEvent ( 'touchend' , path [ len - 1 ] [ 0 ] , path [ len - 1 ] [ 1 ] , options ) ;
31
31
return ;
32
32
}
33
33
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 ) ;
36
36
37
37
path . slice ( 1 , len ) . forEach ( function ( pt ) {
38
38
Lib . clearThrottle ( ) ;
39
- mouseEvent ( 'mousemove' , pt [ 0 ] , pt [ 1 ] ) ;
39
+ mouseEvent ( 'mousemove' , pt [ 0 ] , pt [ 1 ] , options ) ;
40
40
} ) ;
41
41
42
- mouseEvent ( 'mouseup' , path [ len - 1 ] [ 0 ] , path [ len - 1 ] [ 1 ] ) ;
42
+ mouseEvent ( 'mouseup' , path [ len - 1 ] [ 0 ] , path [ len - 1 ] [ 1 ] , options ) ;
43
43
}
44
44
45
45
function assertSelectionNodes ( cornerCnt , outlineCnt ) {
@@ -157,6 +157,43 @@ describe('Test select box and lasso in general:', function() {
157
157
158
158
drag ( selectPath ) ;
159
159
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
+
160
197
selectedPromise . then ( function ( ) {
161
198
expect ( selectingCnt ) . toBe ( 1 , 'with the correct selecting count' ) ;
162
199
assertEventData ( selectingData . points , [ {
@@ -178,8 +215,14 @@ describe('Test select box and lasso in general:', function() {
178
215
x : [ 0.002000 , 0.0046236 ] ,
179
216
y : [ 0.10209191961595454 , 24.512223978291406 ]
180
217
} , '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 , [ {
183
226
curveNumber : 0 ,
184
227
pointNumber : 0 ,
185
228
x : 0.002 ,
@@ -193,15 +236,37 @@ describe('Test select box and lasso in general:', function() {
193
236
y : 12.5 ,
194
237
id : 'id-0.004' ,
195
238
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)' ) ;
201
267
202
268
return doubleClick ( 250 , 200 ) ;
203
269
} )
204
- . then ( deselectPromise )
205
270
. then ( function ( ) {
206
271
expect ( doubleClickData ) . toBe ( null , 'with the correct deselect data' ) ;
207
272
} )
0 commit comments