@@ -321,20 +321,28 @@ describe('sliders interactions', function() {
321
321
322
322
it ( 'should issue events on interaction' , function ( done ) {
323
323
var cntStart = 0 ;
324
- var cntMove = 0 ;
324
+ var cntInteraction = 0 ;
325
+ var cntNonInteraction = 0 ;
325
326
var cntEnd = 0 ;
326
- var cntChange = 0 ;
327
-
328
- gd . on ( 'plotly_sliderdragstart' , function ( ) { cntStart ++ ; } ) ;
329
- gd . on ( 'plotly_sliderdragmove' , function ( ) { cntMove ++ ; } ) ;
330
- gd . on ( 'plotly_sliderdragend' , function ( ) { cntEnd ++ ; } ) ;
331
- gd . on ( 'plotly_sliderchange' , function ( ) { cntChange ++ ; } ) ;
332
-
333
- function assertEventCounts ( starts , moves , ends , changes ) {
334
- expect ( cntStart ) . toEqual ( starts ) ;
335
- expect ( cntMove ) . toEqual ( moves ) ;
336
- expect ( cntEnd ) . toEqual ( ends ) ;
337
- expect ( cntChange ) . toEqual ( changes ) ;
327
+
328
+ gd . on ( 'plotly_sliderstart' , function ( ) {
329
+ cntStart ++ ;
330
+ } ) . on ( 'plotly_sliderchange' , function ( datum ) {
331
+ if ( datum . interaction ) {
332
+ cntInteraction ++ ;
333
+ } else {
334
+ cntNonInteraction ++ ;
335
+ }
336
+ } ) . on ( 'plotly_sliderend' , function ( ) {
337
+ cntEnd ++ ;
338
+ } ) ;
339
+
340
+ function assertEventCounts ( starts , interactions , noninteractions , ends ) {
341
+ expect (
342
+ [ cntStart , cntInteraction , cntNonInteraction , cntEnd ]
343
+ ) . toEqual (
344
+ [ starts , interactions , noninteractions , ends ]
345
+ ) ;
338
346
}
339
347
340
348
assertEventCounts ( 0 , 0 , 0 , 0 ) ;
@@ -350,29 +358,29 @@ describe('sliders interactions', function() {
350
358
} ) ) ;
351
359
352
360
setTimeout ( function ( ) {
353
- // One slider received a mousedown, two linked sliders have received a change:
354
- assertEventCounts ( 1 , 0 , 0 , 2 ) ;
361
+ // One slider received a mousedown, one received an interaction, and one received a change:
362
+ assertEventCounts ( 1 , 1 , 1 , 0 ) ;
355
363
356
- setTimeout ( function ( ) {
357
- // Drag to the left side:
358
- gd . dispatchEvent ( new MouseEvent ( 'mousemove' , {
359
- clientY : touchRect . top + 5 ,
360
- clientX : touchRect . left + 5 ,
361
- } ) ) ;
364
+ // Drag to the left side:
365
+ gd . dispatchEvent ( new MouseEvent ( 'mousemove' , {
366
+ clientY : touchRect . top + 5 ,
367
+ clientX : touchRect . left + 5 ,
368
+ } ) ) ;
362
369
363
- setTimeout ( function ( ) {
364
- // On move, now two linked sliders have received two changes each :
365
- assertEventCounts ( 1 , 1 , 0 , 4 ) ;
370
+ setTimeout ( function ( ) {
371
+ // On move, now to changes for the each slider, and no ends :
372
+ assertEventCounts ( 1 , 2 , 2 , 0 ) ;
366
373
367
- gd . dispatchEvent ( new MouseEvent ( 'mouseup' ) ) ;
374
+ gd . dispatchEvent ( new MouseEvent ( 'mouseup' ) ) ;
368
375
369
- // Now all have been receivd:
370
- assertEventCounts ( 1 , 1 , 1 , 4 ) ;
376
+ setTimeout ( function ( ) {
377
+ // Now an end:
378
+ assertEventCounts ( 1 , 2 , 2 , 1 ) ;
371
379
372
380
done ( ) ;
373
- } , 10 ) ;
374
- } , 10 ) ;
375
- } , 10 ) ;
381
+ } , 50 ) ;
382
+ } , 50 ) ;
383
+ } , 50 ) ;
376
384
} ) ;
377
385
378
386
function assertNodeCount ( query , cnt ) {
0 commit comments