Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
693 steven 1
NProgress
2
=========
3
 
4
[![Status](https://api.travis-ci.org/rstacruz/nprogress.svg?branch=master)](http://travis-ci.org/rstacruz/nprogress)
5
[![npm version](https://img.shields.io/npm/v/nprogress.png)](https://npmjs.org/package/nprogress "View this project on npm")
6
[![jsDelivr Hits](https://data.jsdelivr.com/v1/package/npm/nprogress/badge?style=rounded)](https://www.jsdelivr.com/package/npm/nprogress)
7
 
8
> Minimalist progress bar
9
 
10
Slim progress bars for Ajax'y applications. Inspired by Google, YouTube, and
11
Medium.
12
 
13
Installation
14
------------
15
 
16
Add [nprogress.js] and [nprogress.css] to your project.
17
 
18
```html
19
<script src='nprogress.js'></script>
20
<link rel='stylesheet' href='nprogress.css'/>
21
```
22
 
23
NProgress is available via [bower] and [npm].
24
 
25
    $ npm install --save nprogress
26
 
27
Also available via [unpkg] CDN:
28
 
29
- https://unpkg.com/nprogress@0.2.0/nprogress.js
30
- https://unpkg.com/nprogress@0.2.0/nprogress.css
31
 
32
[bower]: http://bower.io/search/?q=nprogress
33
[npm]: https://www.npmjs.org/package/nprogress
34
[unpkg]: https://unpkg.com/
35
 
36
Basic usage
37
-----------
38
 
39
Simply call `start()` and `done()` to control the progress bar.
40
 
41
~~~ js
42
NProgress.start();;
43
NProgress.done();
44
~~~
45
 
46
### Turbolinks (version 5+)
47
Ensure you're using Turbolinks 5+, and use
48
this: (explained [here](https://github.com/rstacruz/nprogress/issues/8#issuecomment-239107109))
49
 
50
~~~ js
51
$(document).on('turbolinks:click', function() {
52
  NProgress.start();;
53
});
54
$(document).on('turbolinks:render', function() {
55
  NProgress.done();
56
  NProgress.remove();
57
});
58
~~~
59
 
60
### Turbolinks (version 3 and below)
61
Ensure you're using Turbolinks 1.3.0+, and use
62
this: (explained [here](https://github.com/rstacruz/nprogress/issues/8#issuecomment-23010560))
63
 
64
~~~ js
65
$(document).on('page:fetch',   function() { NProgress.start();; });
66
$(document).on('page:change',  function() { NProgress.done(); });
67
$(document).on('page:restore', function() { NProgress.remove(); });
68
~~~
69
 
70
### Pjax
71
Try this: (explained [here](https://github.com/rstacruz/nprogress/issues/22#issuecomment-36540472))
72
 
73
~~~ js
74
$(document).on('pjax:start', function() { NProgress.start();; });
75
$(document).on('pjax:end',   function() { NProgress.done();  });
76
~~~
77
 
78
Ideas
79
-----
80
 
81
 * Add progress to your Ajax calls! Bind it to the jQuery `ajaxStart` and
82
 `ajaxStop` events.
83
 
84
 * Make a fancy loading bar even without Turbolinks/Pjax! Bind it to
85
 `$(document).ready` and `$(window).load`.
86
 
87
Advanced usage
88
--------------
89
 
90
__Percentages:__ To set a progress percentage, call `.set(n)`, where *n* is a
91
number between `0..1`.
92
 
93
~~~ js
94
NProgress.set(0.0);     // Sorta same as .start()
95
NProgress.set(0.4);
96
NProgress.set(1.0);     // Sorta same as .done()
97
~~~
98
 
99
__Incrementing:__ To increment the progress bar, just use `.inc()`. This
100
increments it with a random amount. This will never get to 100%: use it for
101
every image load (or similar).
102
 
103
~~~ js
104
NProgress.inc();
105
~~~
106
 
107
If you want to increment by a specific value, you can pass that as a parameter:
108
 
109
~~~ js
110
NProgress.inc(0.2);    // This will get the current status value and adds 0.2 until status is 0.994
111
~~~
112
 
113
__Force-done:__ By passing `true` to `done()`, it will show the progress bar
114
even if it's not being shown. (The default behavior is that *.done()* will not
115
    do anything if *.start()* isn't called)
116
 
117
~~~ js
118
NProgress.done(true);
119
~~~
120
 
121
__Get the status value:__ To get the status value, use `.status`
122
 
123
Configuration
124
-------------
125
 
126
#### `minimum`
127
Changes the minimum percentage used upon starting. (default: `0.08`)
128
 
129
~~~ js
130
NProgress.configure({ minimum: 0.1 });
131
~~~
132
 
133
#### `template`
134
You can change the markup using `template`. To keep the progress
135
bar working, keep an element with `role='bar'` in there. See the [default template]
136
for reference.
137
 
138
~~~ js
139
NProgress.configure({
140
  template: "<div class='....'>...</div>"
141
});
142
~~~
143
 
144
#### `easing` and `speed`
145
Adjust animation settings using *easing* (a CSS easing string)
146
and *speed* (in ms). (default: `ease` and `200`)
147
 
148
~~~ js
149
NProgress.configure({ easing: 'ease', speed: 500 });
150
~~~
151
 
152
#### `trickle`
153
Turn off the automatic incrementing behavior by setting this to `false`. (default: `true`)
154
 
155
~~~ js
156
NProgress.configure({ trickle: false });
157
~~~
158
 
159
#### `trickleSpeed`
160
Adjust how often to trickle/increment, in ms.
161
 
162
~~~ js
163
NProgress.configure({ trickleSpeed: 200 });
164
~~~
165
 
166
#### `showSpinner`
167
Turn off loading spinner by setting it to false. (default: `true`)
168
 
169
~~~ js
170
NProgress.configure({ showSpinner: false });
171
~~~
172
 
173
#### `parent`
174
specify this to change the parent container. (default: `body`)
175
 
176
~~~ js
177
NProgress.configure({ parent: '#container' });
178
~~~
179
 
180
Customization
181
-------------
182
 
183
Just edit `nprogress.css` to your liking. Tip: you probably only want to find
184
and replace occurrences of `#29d`.
185
 
186
The included CSS file is pretty minimal... in fact, feel free to scrap it and
187
make your own!
188
 
189
Resources
190
---------
191
 
192
 * [New UI Pattern: Website Loading Bars](http://www.usabilitypost.com/2013/08/19/new-ui-pattern-website-loading-bars/) (usabilitypost.com)
193
 
194
Support
195
-------
196
 
197
__Bugs and requests__: submit them through the project's issues tracker.<br>
198
[![Issues](http://img.shields.io/github/issues/rstacruz/nprogress.svg)]( https://github.com/rstacruz/nprogress/issues )
199
 
200
__Questions__: ask them at StackOverflow with the tag *nprogress*.<br>
201
[![StackOverflow](http://img.shields.io/badge/stackoverflow-nprogress-brightgreen.svg)]( http://stackoverflow.com/questions/tagged/nprogress )
202
 
203
__Chat__: join us at gitter.im.<br>
204
[![Chat](http://img.shields.io/badge/gitter-rstacruz/nprogress-brightgreen.svg)]( https://gitter.im/rstacruz/nprogress )
205
 
206
[default template]: https://github.com/rstacruz/nprogress/blob/master/nprogress.js#L31
207
[Turbolinks]: https://github.com/rails/turbolinks
208
[nprogress.js]: http://ricostacruz.com/nprogress/nprogress.js
209
[nprogress.css]: http://ricostacruz.com/nprogress/nprogress.css
210
 
211
Thanks
212
------
213
 
214
**NProgress** © 2013-2017, Rico Sta. Cruz. Released under the [MIT License].<br>
215
Authored and maintained by Rico Sta. Cruz with help from [contributors].
216
 
217
> [ricostacruz.com](http://ricostacruz.com) &nbsp;&middot;&nbsp;
218
> GitHub [@rstacruz](https://github.com/rstacruz) &nbsp;&middot;&nbsp;
219
> Twitter [@rstacruz](https://twitter.com/rstacruz)
220
 
221
[MIT License]: http://mit-license.org/
222
[contributors]: http://github.com/rstacruz/nprogress/contributors
223
 
224
[![](https://img.shields.io/github/followers/rstacruz.svg?style=social&label=@rstacruz)](https://github.com/rstacruz) &nbsp;
225
[![](https://img.shields.io/twitter/follow/rstacruz.svg?style=social&label=@rstacruz)](https://twitter.com/rstacruz)