@@ -13,12 +13,50 @@ suite.addBatch({
1313 } ,
1414 "interrupts the active transition" : function ( d3 ) {
1515 var selection = d3 . select ( "body" ) . append ( "div" ) ,
16- transition = selection . transition ( ) ;
17- assert . equal ( selection . node ( ) . __transition__ . active , 0 ) ; // transition hasn’t yet started
16+ transition = selection . transition ( ) ,
17+ lock = selection . node ( ) . __transition__ ;
18+ assert . equal ( lock . active , 0 ) ; // transition hasn’t yet started
1819 d3 . timer . flush ( ) ;
19- assert . equal ( selection . node ( ) . __transition__ . active , transition . id ) ; // transition has started
20+ assert . equal ( lock . active , transition . id ) ; // transition has started
2021 selection . interrupt ( ) ;
21- assert . isUndefined ( selection . node ( ) . __transition__ ) ; // transition was interrupted
22+ assert . greater ( lock . active , transition . id ) ; // transition was interrupted
23+ assert . lesser ( lock . active , transition . id + 1 ) ; // future transitions not interrupted
24+ assert . isUndefined ( selection . node ( ) . __transition__ ) ; // transition was cleared
25+ } ,
26+ "the interrupted transition’s tweens do not receive any further calls" : function ( d3 ) {
27+ var selection = d3 . select ( "body" ) . append ( "div" ) ,
28+ ticks = 0 ,
29+ transition = selection . transition ( ) . tween ( "test" , function ( ) { return function ( ) { ++ ticks ; } ; } ) ;
30+ d3 . timer . flush ( ) ;
31+ var ticks0 = ticks ;
32+ assert . greater ( ticks0 , 0 ) ;
33+ d3 . timer . flush ( ) ;
34+ var ticks1 = ticks ;
35+ assert . greater ( ticks , ticks0 ) ;
36+ selection . interrupt ( ) ;
37+ d3 . timer . flush ( ) ;
38+ assert . equal ( ticks , ticks1 ) ;
39+ } ,
40+ "the interrupted transition does not emit an end event" : {
41+ topic : function ( d3 ) {
42+ var callback = this . callback ,
43+ selection = d3 . select ( "body" ) . append ( "div" ) ;
44+
45+ selection . transition ( )
46+ . duration ( 250 )
47+ . each ( "end" , function ( ) { callback ( null , "fail" ) ; } ) ;
48+
49+ setTimeout ( function ( ) {
50+ selection . interrupt ( ) ;
51+ } , 100 ) ;
52+
53+ setTimeout ( function ( ) {
54+ callback ( null , "success" ) ;
55+ } , 750 ) ;
56+ } ,
57+ "" : function ( result ) {
58+ assert . equal ( result , "success" ) ;
59+ }
2260 } ,
2361 "does not prevent a future scheduled transition" : function ( d3 ) {
2462 var selection = d3 . select ( "body" ) . append ( "div" ) ,
0 commit comments