-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allowed 0 (zero) value for total/progress initialization #11
- Loading branch information
1 parent
ccce482
commit 7605d2c
Showing
4 changed files
with
10 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,5 @@ gfx/* | |
PublicHtml/* | ||
node_modules* | ||
.tmp* | ||
intern_* | ||
intern_* | ||
dev.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,7 +71,8 @@ Bar.prototype.render = function(){ | |
var s = this.format; | ||
|
||
// calculate the normalized current progress | ||
var progress = this.value/this.total; | ||
// handle NaN Errors | ||
var progress = (this.value/this.total) || 1.0; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
AndiDittrich
Author
Member
|
||
|
||
// limiter | ||
progress = Math.min(Math.max(progress, 0.0), 1.0); | ||
|
@@ -150,7 +151,8 @@ Bar.prototype.formatTime = function (t, roundTo) { | |
Bar.prototype.start = function(total, startValue){ | ||
// set initial values | ||
this.value = startValue || 0; | ||
this.total = total || 100; | ||
this.total = (typeof total !== 'undefined' && total >= 0) ? total : 100; | ||
|
||
this.startTime = Date.now(); | ||
this.lastDrawnString = ''; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This does not work as expected since 0/1 || 1 = 1, so the progressbar can never be 0 onless you use a value like 0.000001 Ithink we need an if statement here