forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuffering.vue
More file actions
56 lines (43 loc) · 1.41 KB
/
Buffering.vue
File metadata and controls
56 lines (43 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<template>
<div class="q-pa-md">
<q-linear-progress :value="progress" :buffer="buffer" />
<q-linear-progress :value="progress" :buffer="buffer" color="warning" class="q-mt-sm" />
<q-linear-progress :value="progress" :buffer="buffer" color="secondary" class="q-mt-sm" />
<q-linear-progress :value="progress" :buffer="buffer" color="accent" class="q-mt-sm" />
<q-linear-progress :value="progress" :buffer="buffer" color="purple" track-color="orange" class="q-mt-sm" />
<q-linear-progress :value="progress" :buffer="buffer" color="negative" class="q-mt-sm" />
</div>
</template>
<script>
import { ref, onMounted, onBeforeUnmount } from 'vue'
export default {
setup () {
const progress = ref(0.01)
const buffer = ref(0.01)
let interval, bufferInterval
onMounted(() => {
interval = setInterval(() => {
if (progress.value >= 1) {
progress.value = 0.01
buffer.value = 0.01
return
}
progress.value = Math.min(1, buffer.value, progress.value + 0.1)
}, 700 + Math.random() * 1000)
bufferInterval = setInterval(() => {
if (buffer.value < 1) {
buffer.value = Math.min(1, buffer.value + Math.random() * 0.2)
}
}, 700)
})
onBeforeUnmount(() => {
clearInterval(interval)
clearInterval(bufferInterval)
})
return {
progress,
buffer
}
}
}
</script>