forked from didi/mand-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.vue
More file actions
117 lines (106 loc) · 2.08 KB
/
index.vue
File metadata and controls
117 lines (106 loc) · 2.08 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
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<template>
<md-activity-indicator-rolling
class="md-progress"
:process="formatValue"
:size="size"
:width="width"
:color="color"
:border-color="borderColor"
:fill="fill"
:linecap="linecap"
:rotate="rotate"
>
<slot></slot>
<template slot="defs">
<slot name="defs"></slot>
</template>
</md-activity-indicator-rolling>
</template>
<script>import Roller from '../activity-indicator/roller'
import {noop, inBrowser} from '../_util'
import Animate from '../_util/animate'
export default {
name: 'md-progress',
components: {
[Roller.name]: Roller,
},
props: {
size: {
type: Number,
default: 70,
},
width: {
type: Number,
},
color: {
type: String,
default: '#2F86F6',
},
borderColor: {
type: String,
default: 'rgba(0, 0, 0, .1)',
},
fill: {
type: String,
default: 'transparent',
},
linecap: {
// butt | round
type: String,
default: 'round',
},
rotate: {
type: Number,
default: 0,
},
value: {
// progress control 0-1
type: Number,
default: 0,
},
transition: {
type: Boolean,
default: false,
},
duration: {
type: Number,
default: 1000,
},
},
data() {
return {
formatValue: 0,
isMounted: false,
}
},
watch: {
value: {
handler(val, oldVal) {
/* istanbul ignore if */
if ((!inBrowser && !this.isMounted) || !this.transition) {
this.formatValue = val
return
}
this.$_doAnimateDisplay(oldVal, val)
},
immediate: true,
},
},
mounted() {
this.isMounted = true
},
methods: {
// MARK: private methods
$_doAnimateDisplay(fromValue = 0, toValue = 0) {
/* istanbul ignore next */
const step = percent => {
this.formatValue = fromValue + (toValue - fromValue) * percent
}
const verify = id => id
/* istanbul ignore next */
Animate.start(step, verify, noop, this.duration)
},
},
}
</script>