| 11 | });});});});});}); |
| 12 | |
| 13 | function Example1(onComplete){ |
| 14 | // EXAMPLE 1 --------------------------------------------- |
| 15 | console.log('\nExample 1 - Standard configuration (4s)'); |
| 16 | // create new progress bar using default values |
| 17 | const b1 = new _progress.Bar(); |
| 18 | b1.start(200, 0); |
| 19 | |
| 20 | // the bar value - will be linear incremented |
| 21 | let value = 0; |
| 22 | |
| 23 | // 20ms update rate |
| 24 | const timer = setInterval(function(){ |
| 25 | // increment value |
| 26 | value++; |
| 27 | |
| 28 | // update the bar value |
| 29 | b1.update(value) |
| 30 | |
| 31 | // set limit |
| 32 | if (value >= b1.getTotal()){ |
| 33 | // stop timer |
| 34 | clearInterval(timer); |
| 35 | |
| 36 | b1.stop(); |
| 37 | |
| 38 | // run complete callback |
| 39 | onComplete.apply(this); |
| 40 | } |
| 41 | }, 20); |
| 42 | } |
| 43 | |
| 44 | |
| 45 | function Example2(onComplete){ |