Reputation: 936
I would like to use jQuery progress bar and add it to the top of the page only when the page is loading (and make it disappear afterwards), a behavior which is somehow similar to the progress bar in GitHub:
How can I do that?
I currently have the following HTML code:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js">
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
</head>
<body>
<div id="content">
<div id="progressbar"></div>
<div id="my-content">
My page content goes here....
</div>
</div>
</body>
Javascript:
$('#progressbar').progressbar({
value: false
});
Upvotes: 3
Views: 7457
Reputation: 433
I'd advise you to use NProgress. It's not using jQuery-UI, but it's really slim and easy to integrate. I've used it in several projects and it worked fine.
With NProgress you don't have to have HTML code, you just need to run the following lines:
NProgress.configure()
if you need some special configurationsNProgress.start()
to start the progress barNProgress.inc()
to increment the progressNProgress.done(true)
once progress completeThat's it! Very easy!
Upvotes: 9
Reputation: 531
I’d suggest using PACE (http://github.hubspot.com/pace/docs/welcome/). It does exactly that and makes it very easy to customize!
Upvotes: 1