This repository was archived by the owner on Nov 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathLinearProgress.vue
82 lines (79 loc) · 2.04 KB
/
LinearProgress.vue
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<template>
<div
role="progressbar"
class="mdc-linear-progress"
>
<div class="mdc-linear-progress__buffering-dots" />
<div class="mdc-linear-progress__buffer" />
<div class="mdc-linear-progress__bar mdc-linear-progress__primary-bar">
<span class="mdc-linear-progress__bar-inner" />
</div>
<div class="mdc-linear-progress__bar mdc-linear-progress__secondary-bar">
<span class="mdc-linear-progress__bar-inner" />
</div>
</div>
</template>
<script>
import { MDCLinearProgress } from '@material/linear-progress'
import { baseComponentMixin, themeClassMixin } from '../base'
export default {
mixins: [baseComponentMixin, themeClassMixin],
props: {
open: {
type: Boolean,
default: false
},
indeterminate: {
type: Boolean,
default: false
},
reverse: {
type: Boolean,
default: false
},
progress: {
type: Number,
validator: (value) => (value >= 0) && (value <= 1),
default: 1
},
buffer: {
type: Number,
validator: (value) => (value >= 0) && (value <= 1),
default: 1
}
},
data () {
return {
mdcLinearProgress: undefined
}
},
watch: {
progress () {
this.mdcLinearProgress.progress = this.progress
},
buffer () {
this.mdcLinearProgress.buffer = this.buffer
},
indeterminate () {
this.mdcLinearProgress.determinate = !this.indeterminate
},
reverse () {
this.mdcLinearProgress.reverse = this.reverse
},
open () {
this.open ? this.mdcLinearProgress.open() : this.mdcLinearProgress.close()
}
},
mounted () {
this.mdcLinearProgress = MDCLinearProgress.attachTo(this.$el)
this.mdcLinearProgress.determinate = !this.indeterminate
this.mdcLinearProgress.reverse = this.reverse
this.mdcLinearProgress.progress = this.progress
this.mdcLinearProgress.buffer = this.buffer
this.open ? this.mdcLinearProgress.open() : this.mdcLinearProgress.close()
},
beforeDestroy () {
this.mdcLinearProgress.destroy()
}
}
</script>