Skip to content
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

Merged
merged 1 commit into from
Sep 2, 2017

Conversation

imaustink
Copy link
Contributor

@imaustink imaustink commented Aug 31, 2017

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:
loading-indicator-desktop
Mobile:
loading-indicator-mobile
Slow 3G Mobile:
loading-indicator-mobile-slow-3g

@imaustink imaustink requested a review from chasenlehara August 31, 2017 22:52
@chasenlehara
Copy link
Member

@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

@imaustink imaustink force-pushed the 391-fix-loading-indicator branch from d9d077f to 03e34c5 Compare September 1, 2017 19:38
@imaustink
Copy link
Contributor Author

@chasenlehara oops! My bad! I've added that.

@imaustink imaustink force-pushed the 391-fix-loading-indicator branch 2 times, most recently from cbe189c to 37bf811 Compare September 1, 2017 20:54
@imaustink
Copy link
Contributor Author

@chasenlehara I made the changes you recommended.

Copy link
Member

@chasenlehara chasenlehara left a 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.

@@ -1,5 +1,7 @@
var starting = 5;
Copy link
Member

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.

clearTimeout(this.timer);
this.timer = null;
}
this.meter.css('width', progress || starting + '%');
Copy link
Member

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.

this.meter.css('width', progress + '%');
if(progress === 100){
this.timer = setTimeout(function(){
console.log('hide');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋

Copy link
Contributor Author

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 😝

@imaustink imaustink force-pushed the 391-fix-loading-indicator branch 2 times, most recently from b6de5f3 to ab8284c Compare September 1, 2017 22:33
@imaustink
Copy link
Contributor Author

@chasenlehara good point! I updated the PR.

Copy link
Member

@chasenlehara chasenlehara left a 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
@imaustink imaustink force-pushed the 391-fix-loading-indicator branch from ab8284c to 2e51408 Compare September 2, 2017 01:26
@imaustink imaustink merged commit b733daf into master Sep 2, 2017
@imaustink imaustink deleted the 391-fix-loading-indicator branch September 2, 2017 01:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve first-load performance
2 participants