How to create a Youtube style loading bar with Rai

2019-02-03 07:18发布

Is there a way to make a Youtube style loading bar (the inter-page across the top bar) with turbo-links.

Turbolinks has loads of different callbacks so you could make a jumpy one across a few steps but is there a way to hook into the progress too?

7条回答
我只想做你的唯一
2楼-- · 2019-02-03 07:40

nprogress-rails is probably just what you need.

查看更多
欢心
3楼-- · 2019-02-03 07:44

Here's another brilliant JS from Hubspot, called Pace.

http://github.hubspot.com/pace/docs/welcome/

查看更多
狗以群分
4楼-- · 2019-02-03 07:50

A jQuery Plugin Called NG Progress JS seem to be having the support for turbo links. Here are the NG Progress & alternatives.

http://www.webiyo.com/2013/09/youtube-style-ajax-progress-bar-using.html

Hope It Helps.

查看更多
可以哭但决不认输i
5楼-- · 2019-02-03 07:57

Assuming you have Turbolinks set up correctly add nProgress JS script to your Rails app asset pipeline i.e the JS and CSS.

Set up nProgress by adding this to your custom JS ...

$(document).on('page:fetch',   function() { NProgress.start(); });
$(document).on('page:change',  function() { NProgress.done(); });
$(document).on('page:restore', function() { NProgress.remove(); });

And that's it.

Ps: Check out the nProgress Github page for more info.

查看更多
相关推荐>>
6楼-- · 2019-02-03 08:01

Was brought up in https://github.com/rails/turbolinks/issues/265

Won't be added to Turbolinks, but shows you a simple reference for how to add it if you need to.

查看更多
smile是对你的礼貌
7楼-- · 2019-02-03 08:04

Nowadays a ProgressBar is included with turbolinks (v.2.5.3)

查看更多
登录 后发表回答