A simple loading bar inside of a webcomponent.
A simple loading bar as a webcomponent without externel dependencies (~3KB).
JSFiddle |
Preview
npm install simple-loading-bar
`
Usage
import the module depending on envirement. Exmpl.:
`javascript
require('simple-loading-bar')
`
It can be used by creating a new element and setting appropriate starting values (end is the most important one, describing 100%):
`javascript
let loadingbar = document.createElement('simple-loading-bar')
loadingbar.end = 2000;
loadingbar.width = 400;
loadingbar.height = 20;
loadingbar.color = 'lightgreen';
loadingbar.backgroundColor = 'lightgray';
document.body.append(loadingbar)
`
Start values should be set before adding it to the DOM.
Finally you can add progress by calling:
`javascript
loadingbar.addProgress(100)
``