Commit 84e8acd6b25c6a0ee91b1246f2cc39444d9ccad1
can reset the progress bar, incase you need to try something twice
Dominic Tarr committed on 7/24/2016, 12:24:13 PMParent: 2ba82fd391fcb12d40a521ed9a2c156d9426de3a
Files changed
index.js | changed |
index.js | ||
---|---|---|
@@ -15,8 +15,9 @@ | ||
15 | 15 | var list = create('ul', 'hyperprogress__list') |
16 | 16 | var error = create('pre', 'hyperprogress__error') |
17 | 17 | var liquid = create('div', 'hyperprogress__liquid', ['.']) |
18 | 18 | var bar = create('div', 'hyperprogress__bar', [liquid]) |
19 | + liquid.style.width = '0%' | |
19 | 20 | |
20 | 21 | var n = 0 |
21 | 22 | |
22 | 23 | var prog = create('div', 'hyperprogress', [ |
@@ -27,9 +28,9 @@ | ||
27 | 28 | ]) |
28 | 29 | |
29 | 30 | prog.complete = function () { |
30 | 31 | liquid.style.width = '100%' |
31 | - progress.classList.add('hyperprogress--complete') | |
32 | + prog.classList.add('hyperprogress--complete') | |
32 | 33 | } |
33 | 34 | |
34 | 35 | prog.next = function (name) { |
35 | 36 | n = Math.min(n+1, steps) |
@@ -45,13 +46,22 @@ | ||
45 | 46 | prog.complete() |
46 | 47 | } |
47 | 48 | |
48 | 49 | prog.fail = function (err) { |
49 | - progress.classList.add('hyperprogress--failed') | |
50 | + prog.classList.add('hyperprogress--failed') | |
50 | 51 | list.lastChild.classList.add('hyperprogress--error') |
51 | 52 | if(err && err.stack) |
52 | 53 | error.textContent = err.stack |
53 | 54 | } |
54 | 55 | |
56 | + prog.reset = function () { | |
57 | + n = 0 | |
58 | + error.innerHTML = list.innerHTML = '' | |
59 | + liquid.style.width = '0%' | |
60 | + return prog | |
61 | + } | |
62 | + | |
55 | 63 | return prog |
56 | 64 | } |
57 | 65 | |
66 | + | |
67 | + |
Built with git-ssb-web