Skip to content

Commit a013d01

Browse files
committed
feat: Further enhancements for QAjaxBar
1 parent 5308ca8 commit a013d01

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

src/components/ajax-bar/QAjaxBar.js

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -149,19 +149,15 @@ export default {
149149
clearTimeout(this.timer)
150150
this.$emit('start')
151151

152-
this.progress = 0
152+
if (this.onScreen) { return }
153153

154-
if (this.onScreen) {
154+
this.progress = 0
155+
this.onScreen = true
156+
this.animate = false
157+
this.timer = setTimeout(() => {
158+
this.animate = true
155159
this.__work()
156-
}
157-
else {
158-
this.onScreen = true
159-
this.animate = false
160-
this.timer = this.$nextTick(() => {
161-
this.animate = true
162-
this.__work()
163-
}, 1)
164-
}
160+
}, 100)
165161
},
166162
increment (amount) {
167163
this.calls > 0 && (this.progress = inc(this.progress, amount))
@@ -174,6 +170,7 @@ export default {
174170
this.$emit('stop')
175171

176172
const end = () => {
173+
this.animate = true
177174
this.progress = 100
178175
this.timer = setTimeout(() => {
179176
this.onScreen = false
@@ -189,10 +186,12 @@ export default {
189186
},
190187

191188
__work () {
192-
this.timer = setTimeout(() => {
193-
this.increment()
194-
this.__work()
195-
}, 100)
189+
if (this.progress < 100) {
190+
this.timer = setTimeout(() => {
191+
this.increment()
192+
this.__work()
193+
}, 100)
194+
}
196195
}
197196
},
198197
mounted () {

0 commit comments

Comments
 (0)