File tree 1 file changed +13
-7
lines changed 1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,10 @@ angular.module('timer', [])
45
45
$scope . clear ( ) ;
46
46
} ) ;
47
47
48
+ $scope . $on ( 'timer-set-countdown' , function ( e , countdown ) {
49
+ $scope . countdown = countdown ;
50
+ } ) ;
51
+
48
52
function resetTimeout ( ) {
49
53
if ( $scope . timeoutId ) {
50
54
clearTimeout ( $scope . timeoutId ) ;
@@ -136,13 +140,6 @@ angular.module('timer', [])
136
140
return ;
137
141
}
138
142
calculateTimeUnits ( ) ;
139
- if ( $scope . countdown > 0 ) {
140
- $scope . countdown -- ;
141
- }
142
- else if ( $scope . countdown <= 0 ) {
143
- $scope . stop ( ) ;
144
- return ;
145
- }
146
143
147
144
//We are not using $timeout for a reason. Please read here - https://github.com/siddii/angular-timer/pull/5
148
145
$scope . timeoutId = setTimeout ( function ( ) {
@@ -151,6 +148,15 @@ angular.module('timer', [])
151
148
} , $scope . interval - adjustment ) ;
152
149
153
150
$scope . $emit ( 'timer-tick' , { timeoutId : $scope . timeoutId , millis : $scope . millis } ) ;
151
+
152
+ if ( $scope . countdown > 0 ) {
153
+ $scope . countdown -- ;
154
+ }
155
+ else if ( $scope . countdown <= 0 ) {
156
+ $scope . stop ( ) ;
157
+ return ;
158
+ }
159
+
154
160
} ;
155
161
156
162
if ( $scope . autoStart === undefined || $scope . autoStart === true ) {
You can’t perform that action at this time.
0 commit comments