-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix bug preventing loading indicator from showing #393
Conversation
@imaustink Could you please add a gif for slow connections? I wasn’t seeing the bar at all with a slow 3G connection, as depicted in #391 |
d9d077f
to
03e34c5
Compare
@chasenlehara oops! My bad! I've added that. |
cbe189c
to
37bf811
Compare
@chasenlehara I made the changes you recommended. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more thing to consider; if update
gets called with 100
multiple times, we should cancel the first timer or ignore subsequent calls so multiple timers aren’t created.
static/loading-bar.js
Outdated
@@ -1,5 +1,7 @@ | |||
var starting = 5; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move this inline since it’s not reused anywhere.
static/loading-bar.js
Outdated
clearTimeout(this.timer); | ||
this.timer = null; | ||
} | ||
this.meter.css('width', progress || starting + '%'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Order of operations here matters. 😊 To make this more clear, I would follow the progress = progress || 5
pattern.
static/loading-bar.js
Outdated
this.meter.css('width', progress + '%'); | ||
if(progress === 100){ | ||
this.timer = setTimeout(function(){ | ||
console.log('hide'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👋
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
face palm I need a linter rule for console.log
😝
b6de5f3
to
ab8284c
Compare
@chasenlehara good point! I updated the PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
Since we have a CSS animation on the width of the bar, and on a fast network the progress event usaully only fires once (at 100%), hiding the loading indicator eminently after calling `.end()` would not allow the animation to complete before the bar hidden. This PR adds a timer to wait for the CSS animation before hiding the bar. closes #392
ab8284c
to
2e51408
Compare
Fix bug preventing loading indicator from showing
Since we have a CSS animation on the width of the bar, and on a fast network the progress event usaully only fires once (at 100%), hiding the loading indicator eminently after calling
.end()
would not allow the animation to complete before the bar hidden.This PR adds a timer to wait for the CSS animation before hiding the bar.
closes #392
Desktop:
Mobile:
Slow 3G Mobile: