Skip to content

Commit

Permalink
Use new turbolinks v5 events
Browse files Browse the repository at this point in the history
Update turblinks v5 events, as recommended by nprogress (rstacruz/nprogress#8 (comment))
I've tested both versions. This gives better UX, imo. There is no delay between clicking a link, and the loading bar appearing, even on really slow connections.
  • Loading branch information
Wolfram Müller authored Oct 20, 2017
1 parent 94ad8fe commit 8588d41
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions app/assets/javascripts/nprogress-turbolinks.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
jQuery(function() {
jQuery(document).on('page:fetch turbolinks:request-start', function() {
NProgress.start();
});
jQuery(document).on('page:receive turbolinks:request-end', function() {
NProgress.set(0.7);
});
jQuery(document).on('page:change turbolinks:load', function() {
NProgress.done();
});
jQuery(document).on('page:restore turbolinks:request-end turbolinks:before-cache', function() {
NProgress.remove();
});
jQuery(document)
.on('turbolinks:click', function() {
NProgress.start();
})
.on('turbolinks:render', function() {
NProgress.done();
NProgress.remove();
});
});

0 comments on commit 8588d41

Please sign in to comment.