Debian Codegraph @

progress-plugin/README.md

raw
1 # Swup Progress Bar Plugin
2
3 A [swup](https://swup.js.org) plugin for displaying a progress bar.
4
5 Shows a loading indicator for requests taking longer than ~300ms.
6
7 ## Installation
8
9 Install the plugin from npm and import it into your bundle.
10
11 ```bash
12 npm install @swup/progress-plugin
13 ```
14
15 ```js
16 import SwupProgressPlugin from '@swup/progress-plugin';
17 ```
18
19 Or include the minified production file from a CDN:
20
21 ```html
22 <script src="https://unpkg.com/@swup/progress-plugin@3"></script>
23 ```
24
25 ## Usage
26
27 To run this plugin, include an instance in the swup options.
28
29 ```javascript
30 const swup = new Swup({
31 plugins: [new SwupProgressPlugin()]
32 });
33 ```
34
35 ## Styling
36
37 The progress bar has a class name of `swup-progress-bar` you can use for styling.
38
39 ```css
40 .swup-progress-bar {
41 height: 4px;
42 background-color: blue;
43 }
44 ```
45
46 ## Options
47
48 ```javascript
49 {
50 className: 'swup-progress-bar',
51 transition: 300,
52 delay: 300,
53 initialValue: 0.25,
54 finishAnimation: true
55 }
56 ```
57
58 ### className
59
60 Class name to use for the container div.
61
62 ### transition
63
64 Length of the CSS transition between loading states, in milliseconds.
65
66 ### delay
67
68 How long to wait before showing the progress bar, in milliseconds.
69
70 Set to `0` to always display the progress bar, even on fast requests.
71
72 ### initialValue
73
74 To create a slightly more "realistic" appearance, the progress bar will start
75 out at a random position beteen 0 and the value of this option. Set to `0` to
76 always start from the left.
77
78 ### finishAnimation
79
80 Whether the progress bar will complete the transition to 100% before hiding.