Google Material Design Progress Linear bar.
It uses CSS3 and vanilla JavaScript which doesn't depend on any other libraries.
Type 1. Determinate
Type 2. Buffer
Type 3. Indeterminate
Type 4. Query Indeterminate and Determinate
Or you can see all types together:
Vedio:Material Progress & activity
Include mprogress.min.js and mprogress.min.css in your target html file.
<linkrel='stylesheet' href='mprogress.min.css'/><scriptsrc='mprogress.min.js'></script>You can also install it via Bower or npm:
bower install --save mprogress
npm install --save mprogress
Example for the Determinate type
1.Instantiation:
varmprogress=newMprogress();2.Show and start the bar by using:
mprogress.start();Or you can just use the following code to replace step 1 and 2:
varmprogress=newMprogress('start');//start it immediately3.Finish the loading and hide it :
mprogress.end();All types have start and end methods.
Determinate also has set and inc methods.
Sets the progress bar status, where n is a number from 0.0 to 1.0.
eg:
mprogress.set(0.3);Increases by a random amount.
eg:
mprogress.inc();// Increase the bar with a random amount.mprogress.inc(0.3);// This will get the current status value and adds 0.3 until status is 0.994Its always used for video loading, and you can use for other case.
Init Type Buffer :
varbufferIntObj={template: 2};varbufferProgress=newMprogress(bufferIntObj);bufferProgress.start();If you want to start it immediately after instantiating it,you can use:
varbufferIntObj={template: 2,// type numberstart: true// start it now};varbufferProgress=newMprogress(bufferIntObj);bufferProgress.end();Buffer also has set , inc and setBuffer methods
Type Buffer has two progress: main progress and buffer progress.
Sets the main progress bar status (0,1)
Sets the buffer progress bar status (0,1)
Increases by a random amount, including buffer bar.
Init Type Indeterminate :
varintObj={template: 3,parent: '#customId'// this option will insert bar HTML into this parent Element };varindeterminateProgress=newMprogress(intObj);Type Indeterminate just has start and end methods.
indeterminateProgress.start();indeterminateProgress.end();Init Type Query :
varintObj={template: 4,parent: '#anothercustomId'// to other position};varqueryProgress=newMprogress(intObj);Type Query just has start and end methods.
queryProgress.start();queryProgress.end();Passing an object(configuration) to instantiated Mprogress
varmp=newMprogress(configuration);template
Set the progress bar type. (default: 1)
varmp=newMprogress({// vaule { // 1: Type Determinate,// 2: Buffer,// 3: Indeterminate, // 4: Query,// '<div>...</div>': 'yourcustomHTML'// }template: 2});parent
Change the parent container where the bar is shown. (default: body)
varmp=newMprogress({parent: '#customContainer'});start
Start the bar immediately. (default: false)
varmp=newMprogress({template: 4,start: true});For type1 Determinate, you can just use:
varmp=newMprogress('start');trickle
trickleRate
trickleSpeed
minimum
easing
positionUsing
speed
Mobile First.
All types work in Chrome and Firefox.
Type Determinate works in all browsers.



