Skip to content

Commit 7516570

Browse files
committed
Last emitted millisecond is 0
Changed the order of execution to make 0 the last emitted millis value for a countdown. Previously the last emit message was the value just before 0. For example with a countdown with an interval of 1000 the last emitted millis value was 1000.
1 parent 8651fd3 commit 7516570

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

dist/angular-timer.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,21 +147,21 @@ angular.module('timer', [])
147147
return;
148148
}
149149
calculateTimeUnits();
150-
if ($scope.countdown > 0) {
151-
$scope.countdown--;
152-
}
153-
else if ($scope.countdown <= 0) {
154-
$scope.stop();
155-
return;
156-
}
157-
158150
//We are not using $timeout for a reason. Please read here - https://github.com/siddii/angular-timer/pull/5
159151
$scope.timeoutId = setTimeout(function () {
160152
tick();
161153
$scope.$digest();
162154
}, $scope.interval - adjustment);
163155

164156
$scope.$emit('timer-tick', {timeoutId: $scope.timeoutId, millis: $scope.millis});
157+
158+
if ($scope.countdown > 0) {
159+
$scope.countdown--;
160+
}
161+
else if ($scope.countdown <= 0) {
162+
$scope.stop();
163+
return;
164+
}
165165
};
166166

167167
if ($scope.autoStart === undefined || $scope.autoStart === true) {

0 commit comments

Comments
 (0)