Or you can just use the following code to replace step 1 and 2:
varmprogress=newMprogress('start');//start it immediately
3.Finish the loading and hide it :
mprogress.end();
Advanced usage
All types have start and end methods.
Type1: Determinate
Determinate also has set and inc methods.
set(n)
Sets the progress bar status, where n is a number from 0.0 to 1.0.
eg:
mprogress.set(0.3);
inc()
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.994
Type2: Buffer
Its always used for video loading, and you can use for other case.
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);
End it:
bufferProgress.end();
Buffer also has set , inc and setBuffer methods
Type Buffer has two progress: main progress and buffer progress.
set(n)
Sets the main progress bar status (0,1)
setBuffer(num)
Sets the buffer progress bar status (0,1)
inc()
Increases by a random amount, including buffer bar.
Type3:Indeterminate
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.
请发表评论