From aeea9b56ac020283062ac44f58df4c292174a897 Mon Sep 17 00:00:00 2001 From: David Resseguie Date: Tue, 10 Feb 2015 11:39:06 -0500 Subject: [PATCH] avoid negative countdown If the countdown is already at zero, don't decrement the time value. It was previously causing negative numbers to be displayed on the countdown clock (00:00:-4) if a start event was received after it had reached zero. --- models/stopwatch.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/models/stopwatch.js b/models/stopwatch.js index 29ace51..a4a64b8 100644 --- a/models/stopwatch.js +++ b/models/stopwatch.js @@ -60,7 +60,9 @@ Stopwatch.prototype.reset = function() { }; Stopwatch.prototype.onTick = function() { - this.time -= this.second; + if(this.time > 0) { + this.time -= this.second; + } var formattedTime = this.formatTime(this.time); this.emit('tick:stopwatch', formattedTime);