File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11var CHECKSUM = {
2- build : '55684a60-5c1b -11e7-8400-af0272f167c9 '
2+ build : 'e049e450-5c1f -11e7-9524-ad80f9e5c5d2 '
33} ;
44module . exports = CHECKSUM ;
Original file line number Diff line number Diff line change @@ -57,12 +57,17 @@ Clock.prototype = {
5757 // Delete old events
5858 for ( var i = 0 ; i < this . _pendingRemoval . length ; i ++ )
5959 {
60- var index = this . _active . indexOf ( this . _pendingRemoval [ i ] ) ;
60+ var event = this . _pendingRemoval [ i ] ;
61+
62+ var index = this . _active . indexOf ( event ) ;
6163
6264 if ( index > - 1 )
6365 {
6466 this . _active . splice ( index , 1 ) ;
6567 }
68+
69+ // Pool them?
70+ event . destroy ( ) ;
6671 }
6772
6873 // Move pending events to the active list
@@ -93,6 +98,11 @@ Clock.prototype = {
9398 {
9499 var event = this . _active [ i ] ;
95100
101+ if ( event . paused )
102+ {
103+ continue ;
104+ }
105+
96106 event . elapsed += elapsed ;
97107
98108 // console.log(event.elapsed);
@@ -105,13 +115,18 @@ Clock.prototype = {
105115 event . elapsed = event . delay ;
106116
107117 // Process the event
108- event . callback . apply ( event . callbackScope , event . args ) ;
118+ if ( ! event . hasDispatched )
119+ {
120+ event . hasDispatched = true ;
121+ event . callback . apply ( event . callbackScope , event . args ) ;
122+ }
109123
110124 if ( event . loop || event . repeatCount > 0 )
111125 {
112126 event . repeatCount -- ;
113127
114128 event . elapsed = remainder ;
129+ event . hasDispatched = false ;
115130 }
116131 else
117132 {
Original file line number Diff line number Diff line change @@ -52,15 +52,54 @@ var TimerEvent = function (config)
5252 */
5353 this . args = GetValue ( config , 'args' , [ ] ) ;
5454
55- this . due = 0 ;
55+ // This works for setting an infinite repeat too
56+ if ( this . repeatCount === - 1 )
57+ {
58+ this . loop = true ;
59+ }
60+
5661 this . elapsed = 0 ;
62+ this . hasDispatched = false ;
63+
64+ // Swap for a getter / setter
65+ this . paused = false ;
5766} ;
5867
5968TimerEvent . prototype = {
6069
6170 getProgress : function ( )
6271 {
6372 return ( this . elapsed / this . delay ) ;
73+ } ,
74+
75+ pause : function ( )
76+ {
77+ this . paused = true ;
78+ } ,
79+
80+ resume : function ( )
81+ {
82+ this . paused = false ;
83+ } ,
84+
85+ remove : function ( dispatchCallback )
86+ {
87+ if ( dispatchCallback === undefined ) { dispatchCallback = false ; }
88+
89+ this . elapsed = this . delay ;
90+
91+ this . hasDispatched = ! ! dispatchCallback ;
92+
93+ this . loop = false ;
94+ this . repeatCount = 0 ;
95+ } ,
96+
97+ // Called internaly, private
98+ destroy : function ( )
99+ {
100+ this . callback = undefined ;
101+ this . callbackScope = undefined ;
102+ this . args . length = 0 ;
64103 }
65104
66105} ;
You can’t perform that action at this time.
0 commit comments