iov-design 2.15.60 → 2.15.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +148 -148
- package/lib/alert.js +24 -105
- package/lib/aside.js +24 -34
- package/lib/autocomplete.js +36 -240
- package/lib/avatar.js +21 -20
- package/lib/backtop.js +27 -52
- package/lib/badge.js +30 -58
- package/lib/breadcrumb-item.js +24 -53
- package/lib/breadcrumb.js +24 -37
- package/lib/button-group.js +24 -29
- package/lib/button.js +38 -60
- package/lib/calendar.js +29 -146
- package/lib/card.js +24 -51
- package/lib/carousel-item.js +30 -68
- package/lib/carousel.js +27 -159
- package/lib/cascader-panel.js +41 -64
- package/lib/cascader.js +37 -470
- package/lib/checkbox-button.js +28 -164
- package/lib/checkbox-group.js +24 -37
- package/lib/checkbox.js +35 -189
- package/lib/col.js +1 -0
- package/lib/collapse-item.js +27 -125
- package/lib/collapse.js +24 -37
- package/lib/color-picker.js +104 -424
- package/lib/container.js +24 -34
- package/lib/date-picker.js +126 -1981
- package/lib/descriptions-item.js +1 -0
- package/lib/descriptions.js +1 -0
- package/lib/dialog.js +24 -137
- package/lib/divider.js +29 -64
- package/lib/drawer.js +24 -139
- package/lib/dropdown-item.js +27 -45
- package/lib/dropdown-menu.js +24 -51
- package/lib/dropdown.js +21 -20
- package/lib/empty.js +24 -61
- package/lib/footer.js +24 -34
- package/lib/form-item.js +42 -128
- package/lib/form.js +27 -40
- package/lib/header.js +24 -34
- package/lib/icon.js +24 -29
- package/lib/image.js +36 -220
- package/lib/index.js +1 -1
- package/lib/infinite-scroll.js +1 -0
- package/lib/input-number.js +30 -163
- package/lib/input.js +42 -274
- package/lib/iov-design.common.js +1635 -11132
- package/lib/link.js +31 -56
- package/lib/loading.js +24 -77
- package/lib/locale/format.js +10 -10
- package/lib/main.js +24 -29
- package/lib/menu-item-group.js +24 -40
- package/lib/menu-item.js +27 -83
- package/lib/menu.js +21 -20
- package/lib/message-box.js +24 -321
- package/lib/message.js +30 -82
- package/lib/mixins/migrating.js +20 -20
- package/lib/notification.js +24 -109
- package/lib/option-group.js +24 -50
- package/lib/option.js +27 -76
- package/lib/page-header.js +24 -56
- package/lib/pagination.js +24 -97
- package/lib/popconfirm.js +24 -97
- package/lib/popover.js +24 -89
- package/lib/progress.js +30 -133
- package/lib/radio-button.js +29 -111
- package/lib/radio-group.js +24 -39
- package/lib/radio.js +36 -152
- package/lib/rate.js +24 -94
- package/lib/result.js +72 -187
- package/lib/row.js +1 -0
- package/lib/scrollbar.js +1 -0
- package/lib/select.js +48 -637
- package/lib/skeleton-item.js +36 -68
- package/lib/skeleton.js +28 -70
- package/lib/slider.js +36 -267
- package/lib/spinner.js +24 -51
- package/lib/statistic.js +24 -76
- package/lib/step.js +29 -118
- package/lib/steps.js +27 -40
- package/lib/submenu.js +21 -20
- package/lib/switch.js +24 -130
- package/lib/tab-pane.js +24 -52
- package/lib/table-column.js +1 -0
- package/lib/table.js +93 -633
- package/lib/tabs.js +34 -49
- package/lib/tag.js +21 -20
- package/lib/theme-chalk/button.css +1 -1
- package/lib/theme-chalk/calendar.css +1 -1
- package/lib/theme-chalk/dropdown.css +1 -1
- package/lib/theme-chalk/index.css +1 -1
- package/lib/theme-chalk/link.css +1 -1
- package/lib/theme-chalk/message-box.css +1 -1
- package/lib/theme-chalk/transfer.css +1 -1
- package/lib/time-picker.js +58 -820
- package/lib/time-select.js +42 -303
- package/lib/timeline-item.js +29 -75
- package/lib/timeline.js +21 -20
- package/lib/tooltip.js +1 -0
- package/lib/transfer.js +36 -299
- package/lib/tree.js +54 -243
- package/lib/upload.js +86 -654
- package/lib/utils/clickoutside.js +7 -7
- package/lib/utils/vue-popper.js +7 -7
- package/package.json +154 -154
- package/packages/autocomplete/src/autocomplete-suggestions.vue +76 -76
- package/packages/autocomplete/src/autocomplete.vue +285 -285
- package/packages/button/src/button.vue +90 -90
- package/packages/calendar/src/date-table.vue +200 -200
- package/packages/calendar/src/main.vue +280 -280
- package/packages/carousel/src/item.vue +138 -138
- package/packages/carousel/src/main.vue +315 -315
- package/packages/cascader/src/cascader.vue +776 -776
- package/packages/cascader-panel/src/cascader-menu.vue +138 -138
- package/packages/cascader-panel/src/cascader-node.vue +246 -246
- package/packages/cascader-panel/src/cascader-panel.vue +391 -391
- package/packages/cascader-panel/src/node.js +166 -166
- package/packages/cascader-panel/src/store.js +58 -58
- package/packages/checkbox/src/checkbox-button.vue +199 -199
- package/packages/checkbox/src/checkbox-group.vue +49 -49
- package/packages/checkbox/src/checkbox.vue +225 -225
- package/packages/collapse/src/collapse-item.vue +114 -114
- package/packages/color-picker/src/components/picker-dropdown.vue +121 -121
- package/packages/color-picker/src/main.vue +188 -188
- package/packages/date-picker/src/basic/date-table.vue +441 -441
- package/packages/date-picker/src/basic/month-table.vue +269 -269
- package/packages/date-picker/src/basic/time-spinner.vue +304 -304
- package/packages/date-picker/src/basic/year-table.vue +111 -111
- package/packages/date-picker/src/panel/date-range.vue +680 -680
- package/packages/date-picker/src/panel/date.vue +609 -609
- package/packages/date-picker/src/panel/month-range.vue +289 -289
- package/packages/date-picker/src/panel/time-range.vue +248 -248
- package/packages/date-picker/src/panel/time-select.vue +178 -178
- package/packages/date-picker/src/panel/time.vue +186 -186
- package/packages/date-picker/src/picker.vue +967 -967
- package/packages/descriptions/src/index.js +180 -180
- package/packages/dialog/src/component.vue +262 -262
- package/packages/drawer/src/main.vue +205 -205
- package/packages/dropdown/src/dropdown-item.vue +37 -37
- package/packages/dropdown/src/dropdown-menu.vue +63 -63
- package/packages/dropdown/src/dropdown.vue +293 -293
- package/packages/empty/src/index.vue +70 -70
- package/packages/form/src/form-item.vue +324 -324
- package/packages/form/src/form.vue +182 -182
- package/packages/image/src/image-viewer.vue +330 -330
- package/packages/image/src/main.vue +249 -249
- package/packages/infinite-scroll/src/main.js +150 -150
- package/packages/input/src/input.vue +477 -477
- package/packages/input-number/src/input-number.vue +283 -283
- package/packages/loading/src/directive.js +133 -133
- package/packages/loading/src/index.js +106 -106
- package/packages/menu/src/menu-item.vue +112 -112
- package/packages/menu/src/menu.vue +325 -325
- package/packages/menu/src/submenu.vue +349 -349
- package/packages/message/src/main.js +91 -91
- package/packages/message-box/src/main.js +216 -216
- package/packages/message-box/src/main.vue +333 -333
- package/packages/notification/src/main.js +94 -94
- package/packages/page-header/src/main.vue +30 -30
- package/packages/pagination/src/pagination.js +390 -390
- package/packages/popconfirm/src/main.vue +104 -104
- package/packages/popover/src/main.vue +239 -239
- package/packages/radio/src/radio-button.vue +115 -115
- package/packages/radio/src/radio-group.vue +115 -115
- package/packages/radio/src/radio.vue +148 -148
- package/packages/rate/src/main.vue +348 -348
- package/packages/scrollbar/src/bar.js +92 -92
- package/packages/scrollbar/src/main.js +130 -130
- package/packages/select/src/option-group.vue +60 -60
- package/packages/select/src/option.vue +171 -171
- package/packages/select/src/select-dropdown.vue +74 -74
- package/packages/select/src/select.vue +979 -979
- package/packages/slider/src/button.vue +238 -238
- package/packages/slider/src/main.vue +427 -427
- package/packages/statistic/src/main.vue +204 -204
- package/packages/steps/src/steps.vue +68 -68
- package/packages/switch/src/component.vue +182 -182
- package/packages/table/src/config.js +153 -153
- package/packages/table/src/filter-panel.vue +194 -194
- package/packages/table/src/store/current.js +76 -76
- package/packages/table/src/store/helper.js +41 -41
- package/packages/table/src/store/index.js +147 -147
- package/packages/table/src/store/watcher.js +502 -502
- package/packages/table/src/table-body.js +469 -469
- package/packages/table/src/table-column.js +328 -328
- package/packages/table/src/table-header.js +571 -571
- package/packages/table/src/table-layout.js +249 -249
- package/packages/table/src/table-row.js +101 -101
- package/packages/table/src/table.vue +740 -740
- package/packages/table/src/util.js +273 -273
- package/packages/tabs/src/tab-bar.vue +57 -57
- package/packages/tabs/src/tab-nav.vue +294 -294
- package/packages/tabs/src/tabs.vue +201 -201
- package/packages/theme-chalk/src/button.scss +416 -416
- package/packages/theme-chalk/src/cascader.scss +252 -252
- package/packages/theme-chalk/src/checkbox.scss +419 -419
- package/packages/theme-chalk/src/common/var.scss +795 -795
- package/packages/theme-chalk/src/form.scss +201 -201
- package/packages/theme-chalk/src/input.scss +591 -591
- package/packages/theme-chalk/src/iovfont.scss +803 -803
- package/packages/theme-chalk/src/link.scss +8 -8
- package/packages/theme-chalk/src/message-box.scss +207 -207
- package/packages/theme-chalk/src/mixins/_button.scss +136 -136
- package/packages/theme-chalk/src/mixins/mixins.scss +190 -190
- package/packages/theme-chalk/src/radio-button.scss +115 -115
- package/packages/theme-chalk/src/select.scss +270 -270
- package/packages/theme-chalk/src/tabs.scss +755 -755
- package/packages/theme-chalk/src/upload.scss +568 -568
- package/packages/tooltip/src/main.js +242 -242
- package/packages/transfer/src/main.vue +231 -231
- package/packages/transfer/src/transfer-panel.vue +251 -251
- package/packages/tree/src/model/node.js +484 -484
- package/packages/tree/src/tree-node.vue +279 -279
- package/packages/tree/src/tree.vue +496 -496
- package/packages/upload/src/index.vue +420 -420
- package/packages/upload/src/upload-file.vue +98 -98
- package/packages/upload/src/upload-list.vue +115 -115
- package/packages/upload/src/upload-picture.vue +98 -98
- package/packages/upload/src/upload.vue +231 -231
- package/packages/upload/src/utils.js +31 -31
- package/src/directives/repeat-click.js +26 -26
- package/src/index.js +259 -259
- package/src/locale/format.js +46 -46
- package/src/locale/index.js +48 -48
- package/src/locale/lang/lo-LA.js +126 -126
- package/src/mixins/locale.js +9 -9
- package/src/mixins/migrating.js +54 -54
- package/src/transitions/collapse-transition.js +77 -77
- package/src/utils/clickoutside.js +76 -76
- package/src/utils/date-util.js +282 -282
- package/src/utils/popup/index.js +218 -218
- package/src/utils/popup/popup-manager.js +194 -194
- package/src/utils/util.js +245 -245
- package/src/utils/vdom.js +5 -5
- package/src/utils/vue-popper.js +198 -198
|
@@ -1,427 +1,427 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div
|
|
3
|
-
class="el-slider"
|
|
4
|
-
:class="{ 'is-vertical': vertical, 'el-slider--with-input': showInput }"
|
|
5
|
-
role="slider"
|
|
6
|
-
:aria-valuemin="min"
|
|
7
|
-
:aria-valuemax="max"
|
|
8
|
-
:aria-orientation="vertical ? 'vertical': 'horizontal'"
|
|
9
|
-
:aria-disabled="sliderDisabled"
|
|
10
|
-
>
|
|
11
|
-
<el-input-number
|
|
12
|
-
v-model="firstValue"
|
|
13
|
-
v-if="showInput && !range"
|
|
14
|
-
class="el-slider__input"
|
|
15
|
-
ref="input"
|
|
16
|
-
@change="emitChange"
|
|
17
|
-
:step="step"
|
|
18
|
-
:disabled="sliderDisabled"
|
|
19
|
-
:controls="showInputControls"
|
|
20
|
-
:min="min"
|
|
21
|
-
:max="max"
|
|
22
|
-
:debounce="debounce"
|
|
23
|
-
:size="inputSize">
|
|
24
|
-
</el-input-number>
|
|
25
|
-
<div
|
|
26
|
-
class="el-slider__runway"
|
|
27
|
-
:class="{ 'show-input': showInput, 'disabled': sliderDisabled }"
|
|
28
|
-
:style="runwayStyle"
|
|
29
|
-
@click="onSliderClick"
|
|
30
|
-
ref="slider">
|
|
31
|
-
<div
|
|
32
|
-
class="el-slider__bar"
|
|
33
|
-
:style="barStyle">
|
|
34
|
-
</div>
|
|
35
|
-
<slider-button
|
|
36
|
-
:vertical="vertical"
|
|
37
|
-
v-model="firstValue"
|
|
38
|
-
:tooltip-class="tooltipClass"
|
|
39
|
-
ref="button1">
|
|
40
|
-
</slider-button>
|
|
41
|
-
<slider-button
|
|
42
|
-
:vertical="vertical"
|
|
43
|
-
v-model="secondValue"
|
|
44
|
-
:tooltip-class="tooltipClass"
|
|
45
|
-
ref="button2"
|
|
46
|
-
v-if="range">
|
|
47
|
-
</slider-button>
|
|
48
|
-
<div
|
|
49
|
-
class="el-slider__stop"
|
|
50
|
-
v-for="(item, key) in stops"
|
|
51
|
-
:key="key"
|
|
52
|
-
:style="getStopStyle(item)"
|
|
53
|
-
v-if="showStops">
|
|
54
|
-
</div>
|
|
55
|
-
<template v-if="markList.length > 0">
|
|
56
|
-
<div>
|
|
57
|
-
<div
|
|
58
|
-
v-for="(item, key) in markList"
|
|
59
|
-
:style="getStopStyle(item.position)"
|
|
60
|
-
class="el-slider__stop el-slider__marks-stop"
|
|
61
|
-
:key="key">
|
|
62
|
-
</div>
|
|
63
|
-
</div>
|
|
64
|
-
<div class="el-slider__marks">
|
|
65
|
-
<slider-marker
|
|
66
|
-
:mark="item.mark" v-for="(item, key) in markList"
|
|
67
|
-
:key="key"
|
|
68
|
-
:style="getStopStyle(item.position)">
|
|
69
|
-
</slider-marker>
|
|
70
|
-
</div>
|
|
71
|
-
</template>
|
|
72
|
-
</div>
|
|
73
|
-
</div>
|
|
74
|
-
</template>
|
|
75
|
-
|
|
76
|
-
<script type="text/babel">
|
|
77
|
-
import ElInputNumber from 'iov-design/packages/input-number';
|
|
78
|
-
import SliderButton from './button.vue';
|
|
79
|
-
import SliderMarker from './marker';
|
|
80
|
-
import Emitter from 'iov-design/src/mixins/emitter';
|
|
81
|
-
|
|
82
|
-
export default {
|
|
83
|
-
name: 'ElSlider',
|
|
84
|
-
|
|
85
|
-
mixins: [Emitter],
|
|
86
|
-
|
|
87
|
-
inject: {
|
|
88
|
-
elForm: {
|
|
89
|
-
default: ''
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
props: {
|
|
94
|
-
min: {
|
|
95
|
-
type: Number,
|
|
96
|
-
default: 0
|
|
97
|
-
},
|
|
98
|
-
max: {
|
|
99
|
-
type: Number,
|
|
100
|
-
default: 100
|
|
101
|
-
},
|
|
102
|
-
step: {
|
|
103
|
-
type: Number,
|
|
104
|
-
default: 1
|
|
105
|
-
},
|
|
106
|
-
value: {
|
|
107
|
-
type: [Number, Array],
|
|
108
|
-
default: 0
|
|
109
|
-
},
|
|
110
|
-
showInput: {
|
|
111
|
-
type: Boolean,
|
|
112
|
-
default: false
|
|
113
|
-
},
|
|
114
|
-
showInputControls: {
|
|
115
|
-
type: Boolean,
|
|
116
|
-
default: true
|
|
117
|
-
},
|
|
118
|
-
inputSize: {
|
|
119
|
-
type: String,
|
|
120
|
-
default: 'small'
|
|
121
|
-
},
|
|
122
|
-
showStops: {
|
|
123
|
-
type: Boolean,
|
|
124
|
-
default: false
|
|
125
|
-
},
|
|
126
|
-
showTooltip: {
|
|
127
|
-
type: Boolean,
|
|
128
|
-
default: true
|
|
129
|
-
},
|
|
130
|
-
formatTooltip: Function,
|
|
131
|
-
disabled: {
|
|
132
|
-
type: Boolean,
|
|
133
|
-
default: false
|
|
134
|
-
},
|
|
135
|
-
range: {
|
|
136
|
-
type: Boolean,
|
|
137
|
-
default: false
|
|
138
|
-
},
|
|
139
|
-
vertical: {
|
|
140
|
-
type: Boolean,
|
|
141
|
-
default: false
|
|
142
|
-
},
|
|
143
|
-
height: {
|
|
144
|
-
type: String
|
|
145
|
-
},
|
|
146
|
-
debounce: {
|
|
147
|
-
type: Number,
|
|
148
|
-
default: 300
|
|
149
|
-
},
|
|
150
|
-
label: {
|
|
151
|
-
type: String
|
|
152
|
-
},
|
|
153
|
-
tooltipClass: String,
|
|
154
|
-
marks: Object
|
|
155
|
-
},
|
|
156
|
-
|
|
157
|
-
components: {
|
|
158
|
-
ElInputNumber,
|
|
159
|
-
SliderButton,
|
|
160
|
-
SliderMarker
|
|
161
|
-
},
|
|
162
|
-
|
|
163
|
-
data() {
|
|
164
|
-
return {
|
|
165
|
-
firstValue: null,
|
|
166
|
-
secondValue: null,
|
|
167
|
-
oldValue: null,
|
|
168
|
-
dragging: false,
|
|
169
|
-
sliderSize: 1
|
|
170
|
-
};
|
|
171
|
-
},
|
|
172
|
-
|
|
173
|
-
watch: {
|
|
174
|
-
value(val, oldVal) {
|
|
175
|
-
if (this.dragging ||
|
|
176
|
-
Array.isArray(val) &&
|
|
177
|
-
Array.isArray(oldVal) &&
|
|
178
|
-
val.every((item, index) => item === oldVal[index])) {
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
this.setValues();
|
|
182
|
-
},
|
|
183
|
-
|
|
184
|
-
dragging(val) {
|
|
185
|
-
if (!val) {
|
|
186
|
-
this.setValues();
|
|
187
|
-
}
|
|
188
|
-
},
|
|
189
|
-
|
|
190
|
-
firstValue(val) {
|
|
191
|
-
if (this.range) {
|
|
192
|
-
this.$emit('input', [this.minValue, this.maxValue]);
|
|
193
|
-
} else {
|
|
194
|
-
this.$emit('input', val);
|
|
195
|
-
}
|
|
196
|
-
},
|
|
197
|
-
|
|
198
|
-
secondValue() {
|
|
199
|
-
if (this.range) {
|
|
200
|
-
this.$emit('input', [this.minValue, this.maxValue]);
|
|
201
|
-
}
|
|
202
|
-
},
|
|
203
|
-
|
|
204
|
-
min() {
|
|
205
|
-
this.setValues();
|
|
206
|
-
},
|
|
207
|
-
|
|
208
|
-
max() {
|
|
209
|
-
this.setValues();
|
|
210
|
-
}
|
|
211
|
-
},
|
|
212
|
-
|
|
213
|
-
methods: {
|
|
214
|
-
valueChanged() {
|
|
215
|
-
if (this.range) {
|
|
216
|
-
return ![this.minValue, this.maxValue]
|
|
217
|
-
.every((item, index) => item === this.oldValue[index]);
|
|
218
|
-
} else {
|
|
219
|
-
return this.value !== this.oldValue;
|
|
220
|
-
}
|
|
221
|
-
},
|
|
222
|
-
setValues() {
|
|
223
|
-
if (this.min > this.max) {
|
|
224
|
-
console.error('[Element Error][Slider]min should not be greater than max.');
|
|
225
|
-
return;
|
|
226
|
-
}
|
|
227
|
-
const val = this.value;
|
|
228
|
-
if (this.range && Array.isArray(val)) {
|
|
229
|
-
if (val[1] < this.min) {
|
|
230
|
-
this.$emit('input', [this.min, this.min]);
|
|
231
|
-
} else if (val[0] > this.max) {
|
|
232
|
-
this.$emit('input', [this.max, this.max]);
|
|
233
|
-
} else if (val[0] < this.min) {
|
|
234
|
-
this.$emit('input', [this.min, val[1]]);
|
|
235
|
-
} else if (val[1] > this.max) {
|
|
236
|
-
this.$emit('input', [val[0], this.max]);
|
|
237
|
-
} else {
|
|
238
|
-
this.firstValue = val[0];
|
|
239
|
-
this.secondValue = val[1];
|
|
240
|
-
if (this.valueChanged()) {
|
|
241
|
-
this.dispatch('ElFormItem', 'el.form.change', [this.minValue, this.maxValue]);
|
|
242
|
-
this.oldValue = val.slice();
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
} else if (!this.range && typeof val === 'number' && !isNaN(val)) {
|
|
246
|
-
if (val < this.min) {
|
|
247
|
-
this.$emit('input', this.min);
|
|
248
|
-
} else if (val > this.max) {
|
|
249
|
-
this.$emit('input', this.max);
|
|
250
|
-
} else {
|
|
251
|
-
this.firstValue = val;
|
|
252
|
-
if (this.valueChanged()) {
|
|
253
|
-
this.dispatch('ElFormItem', 'el.form.change', val);
|
|
254
|
-
this.oldValue = val;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
},
|
|
259
|
-
|
|
260
|
-
setPosition(percent) {
|
|
261
|
-
const targetValue = this.min + percent * (this.max - this.min) / 100;
|
|
262
|
-
if (!this.range) {
|
|
263
|
-
this.$refs.button1.setPosition(percent);
|
|
264
|
-
return;
|
|
265
|
-
}
|
|
266
|
-
let button;
|
|
267
|
-
if (Math.abs(this.minValue - targetValue) < Math.abs(this.maxValue - targetValue)) {
|
|
268
|
-
button = this.firstValue < this.secondValue ? 'button1' : 'button2';
|
|
269
|
-
} else {
|
|
270
|
-
button = this.firstValue > this.secondValue ? 'button1' : 'button2';
|
|
271
|
-
}
|
|
272
|
-
this.$refs[button].setPosition(percent);
|
|
273
|
-
},
|
|
274
|
-
|
|
275
|
-
onSliderClick(event) {
|
|
276
|
-
if (this.sliderDisabled || this.dragging) return;
|
|
277
|
-
this.resetSize();
|
|
278
|
-
if (this.vertical) {
|
|
279
|
-
const sliderOffsetBottom = this.$refs.slider.getBoundingClientRect().bottom;
|
|
280
|
-
this.setPosition((sliderOffsetBottom - event.clientY) / this.sliderSize * 100);
|
|
281
|
-
} else {
|
|
282
|
-
const sliderOffsetLeft = this.$refs.slider.getBoundingClientRect().left;
|
|
283
|
-
this.setPosition((event.clientX - sliderOffsetLeft) / this.sliderSize * 100);
|
|
284
|
-
}
|
|
285
|
-
this.emitChange();
|
|
286
|
-
},
|
|
287
|
-
|
|
288
|
-
resetSize() {
|
|
289
|
-
if (this.$refs.slider) {
|
|
290
|
-
this.sliderSize = this.$refs.slider[`client${ this.vertical ? 'Height' : 'Width' }`];
|
|
291
|
-
}
|
|
292
|
-
},
|
|
293
|
-
|
|
294
|
-
emitChange() {
|
|
295
|
-
this.$nextTick(() => {
|
|
296
|
-
this.$emit('change', this.range ? [this.minValue, this.maxValue] : this.value);
|
|
297
|
-
});
|
|
298
|
-
},
|
|
299
|
-
|
|
300
|
-
getStopStyle(position) {
|
|
301
|
-
return this.vertical ? { 'bottom': position + '%' } : { 'left': position + '%' };
|
|
302
|
-
}
|
|
303
|
-
},
|
|
304
|
-
|
|
305
|
-
computed: {
|
|
306
|
-
stops() {
|
|
307
|
-
if (!this.showStops || this.min > this.max) return [];
|
|
308
|
-
if (this.step === 0) {
|
|
309
|
-
process.env.NODE_ENV !== 'production' &&
|
|
310
|
-
console.warn('[Element Warn][Slider]step should not be 0.');
|
|
311
|
-
return [];
|
|
312
|
-
}
|
|
313
|
-
const stopCount = (this.max - this.min) / this.step;
|
|
314
|
-
const stepWidth = 100 * this.step / (this.max - this.min);
|
|
315
|
-
const result = [];
|
|
316
|
-
for (let i = 1; i < stopCount; i++) {
|
|
317
|
-
result.push(i * stepWidth);
|
|
318
|
-
}
|
|
319
|
-
if (this.range) {
|
|
320
|
-
return result.filter(step => {
|
|
321
|
-
return step < 100 * (this.minValue - this.min) / (this.max - this.min) ||
|
|
322
|
-
step > 100 * (this.maxValue - this.min) / (this.max - this.min);
|
|
323
|
-
});
|
|
324
|
-
} else {
|
|
325
|
-
return result.filter(step => step > 100 * (this.firstValue - this.min) / (this.max - this.min));
|
|
326
|
-
}
|
|
327
|
-
},
|
|
328
|
-
|
|
329
|
-
markList() {
|
|
330
|
-
if (!this.marks) {
|
|
331
|
-
return [];
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
const marksKeys = Object.keys(this.marks);
|
|
335
|
-
return marksKeys.map(parseFloat)
|
|
336
|
-
.sort((a, b) => a - b)
|
|
337
|
-
.filter(point => point <= this.max && point >= this.min)
|
|
338
|
-
.map(point => ({
|
|
339
|
-
point,
|
|
340
|
-
position: (point - this.min) * 100 / (this.max - this.min),
|
|
341
|
-
mark: this.marks[point]
|
|
342
|
-
}));
|
|
343
|
-
},
|
|
344
|
-
|
|
345
|
-
minValue() {
|
|
346
|
-
return Math.min(this.firstValue, this.secondValue);
|
|
347
|
-
},
|
|
348
|
-
|
|
349
|
-
maxValue() {
|
|
350
|
-
return Math.max(this.firstValue, this.secondValue);
|
|
351
|
-
},
|
|
352
|
-
|
|
353
|
-
barSize() {
|
|
354
|
-
return this.range
|
|
355
|
-
? `${ 100 * (this.maxValue - this.minValue) / (this.max - this.min) }%`
|
|
356
|
-
: `${ 100 * (this.firstValue - this.min) / (this.max - this.min) }%`;
|
|
357
|
-
},
|
|
358
|
-
|
|
359
|
-
barStart() {
|
|
360
|
-
return this.range
|
|
361
|
-
? `${ 100 * (this.minValue - this.min) / (this.max - this.min) }%`
|
|
362
|
-
: '0%';
|
|
363
|
-
},
|
|
364
|
-
|
|
365
|
-
precision() {
|
|
366
|
-
let precisions = [this.min, this.max, this.step].map(item => {
|
|
367
|
-
let decimal = ('' + item).split('.')[1];
|
|
368
|
-
return decimal ? decimal.length : 0;
|
|
369
|
-
});
|
|
370
|
-
return Math.max.apply(null, precisions);
|
|
371
|
-
},
|
|
372
|
-
|
|
373
|
-
runwayStyle() {
|
|
374
|
-
return this.vertical ? { height: this.height } : {};
|
|
375
|
-
},
|
|
376
|
-
|
|
377
|
-
barStyle() {
|
|
378
|
-
return this.vertical
|
|
379
|
-
? {
|
|
380
|
-
height: this.barSize,
|
|
381
|
-
bottom: this.barStart
|
|
382
|
-
} : {
|
|
383
|
-
width: this.barSize,
|
|
384
|
-
left: this.barStart
|
|
385
|
-
};
|
|
386
|
-
},
|
|
387
|
-
|
|
388
|
-
sliderDisabled() {
|
|
389
|
-
return this.disabled || (this.elForm || {}).disabled;
|
|
390
|
-
}
|
|
391
|
-
},
|
|
392
|
-
|
|
393
|
-
mounted() {
|
|
394
|
-
let valuetext;
|
|
395
|
-
if (this.range) {
|
|
396
|
-
if (Array.isArray(this.value)) {
|
|
397
|
-
this.firstValue = Math.max(this.min, this.value[0]);
|
|
398
|
-
this.secondValue = Math.min(this.max, this.value[1]);
|
|
399
|
-
} else {
|
|
400
|
-
this.firstValue = this.min;
|
|
401
|
-
this.secondValue = this.max;
|
|
402
|
-
}
|
|
403
|
-
this.oldValue = [this.firstValue, this.secondValue];
|
|
404
|
-
valuetext = `${this.firstValue}-${this.secondValue}`;
|
|
405
|
-
} else {
|
|
406
|
-
if (typeof this.value !== 'number' || isNaN(this.value)) {
|
|
407
|
-
this.firstValue = this.min;
|
|
408
|
-
} else {
|
|
409
|
-
this.firstValue = Math.min(this.max, Math.max(this.min, this.value));
|
|
410
|
-
}
|
|
411
|
-
this.oldValue = this.firstValue;
|
|
412
|
-
valuetext = this.firstValue;
|
|
413
|
-
}
|
|
414
|
-
this.$el.setAttribute('aria-valuetext', valuetext);
|
|
415
|
-
|
|
416
|
-
// label screen reader
|
|
417
|
-
this.$el.setAttribute('aria-label', this.label ? this.label : `slider between ${this.min} and ${this.max}`);
|
|
418
|
-
|
|
419
|
-
this.resetSize();
|
|
420
|
-
window.addEventListener('resize', this.resetSize);
|
|
421
|
-
},
|
|
422
|
-
|
|
423
|
-
beforeDestroy() {
|
|
424
|
-
window.removeEventListener('resize', this.resetSize);
|
|
425
|
-
}
|
|
426
|
-
};
|
|
427
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="el-slider"
|
|
4
|
+
:class="{ 'is-vertical': vertical, 'el-slider--with-input': showInput }"
|
|
5
|
+
role="slider"
|
|
6
|
+
:aria-valuemin="min"
|
|
7
|
+
:aria-valuemax="max"
|
|
8
|
+
:aria-orientation="vertical ? 'vertical': 'horizontal'"
|
|
9
|
+
:aria-disabled="sliderDisabled"
|
|
10
|
+
>
|
|
11
|
+
<el-input-number
|
|
12
|
+
v-model="firstValue"
|
|
13
|
+
v-if="showInput && !range"
|
|
14
|
+
class="el-slider__input"
|
|
15
|
+
ref="input"
|
|
16
|
+
@change="emitChange"
|
|
17
|
+
:step="step"
|
|
18
|
+
:disabled="sliderDisabled"
|
|
19
|
+
:controls="showInputControls"
|
|
20
|
+
:min="min"
|
|
21
|
+
:max="max"
|
|
22
|
+
:debounce="debounce"
|
|
23
|
+
:size="inputSize">
|
|
24
|
+
</el-input-number>
|
|
25
|
+
<div
|
|
26
|
+
class="el-slider__runway"
|
|
27
|
+
:class="{ 'show-input': showInput, 'disabled': sliderDisabled }"
|
|
28
|
+
:style="runwayStyle"
|
|
29
|
+
@click="onSliderClick"
|
|
30
|
+
ref="slider">
|
|
31
|
+
<div
|
|
32
|
+
class="el-slider__bar"
|
|
33
|
+
:style="barStyle">
|
|
34
|
+
</div>
|
|
35
|
+
<slider-button
|
|
36
|
+
:vertical="vertical"
|
|
37
|
+
v-model="firstValue"
|
|
38
|
+
:tooltip-class="tooltipClass"
|
|
39
|
+
ref="button1">
|
|
40
|
+
</slider-button>
|
|
41
|
+
<slider-button
|
|
42
|
+
:vertical="vertical"
|
|
43
|
+
v-model="secondValue"
|
|
44
|
+
:tooltip-class="tooltipClass"
|
|
45
|
+
ref="button2"
|
|
46
|
+
v-if="range">
|
|
47
|
+
</slider-button>
|
|
48
|
+
<div
|
|
49
|
+
class="el-slider__stop"
|
|
50
|
+
v-for="(item, key) in stops"
|
|
51
|
+
:key="key"
|
|
52
|
+
:style="getStopStyle(item)"
|
|
53
|
+
v-if="showStops">
|
|
54
|
+
</div>
|
|
55
|
+
<template v-if="markList.length > 0">
|
|
56
|
+
<div>
|
|
57
|
+
<div
|
|
58
|
+
v-for="(item, key) in markList"
|
|
59
|
+
:style="getStopStyle(item.position)"
|
|
60
|
+
class="el-slider__stop el-slider__marks-stop"
|
|
61
|
+
:key="key">
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
<div class="el-slider__marks">
|
|
65
|
+
<slider-marker
|
|
66
|
+
:mark="item.mark" v-for="(item, key) in markList"
|
|
67
|
+
:key="key"
|
|
68
|
+
:style="getStopStyle(item.position)">
|
|
69
|
+
</slider-marker>
|
|
70
|
+
</div>
|
|
71
|
+
</template>
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
</template>
|
|
75
|
+
|
|
76
|
+
<script type="text/babel">
|
|
77
|
+
import ElInputNumber from 'iov-design/packages/input-number';
|
|
78
|
+
import SliderButton from './button.vue';
|
|
79
|
+
import SliderMarker from './marker';
|
|
80
|
+
import Emitter from 'iov-design/src/mixins/emitter';
|
|
81
|
+
|
|
82
|
+
export default {
|
|
83
|
+
name: 'ElSlider',
|
|
84
|
+
|
|
85
|
+
mixins: [Emitter],
|
|
86
|
+
|
|
87
|
+
inject: {
|
|
88
|
+
elForm: {
|
|
89
|
+
default: ''
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
props: {
|
|
94
|
+
min: {
|
|
95
|
+
type: Number,
|
|
96
|
+
default: 0
|
|
97
|
+
},
|
|
98
|
+
max: {
|
|
99
|
+
type: Number,
|
|
100
|
+
default: 100
|
|
101
|
+
},
|
|
102
|
+
step: {
|
|
103
|
+
type: Number,
|
|
104
|
+
default: 1
|
|
105
|
+
},
|
|
106
|
+
value: {
|
|
107
|
+
type: [Number, Array],
|
|
108
|
+
default: 0
|
|
109
|
+
},
|
|
110
|
+
showInput: {
|
|
111
|
+
type: Boolean,
|
|
112
|
+
default: false
|
|
113
|
+
},
|
|
114
|
+
showInputControls: {
|
|
115
|
+
type: Boolean,
|
|
116
|
+
default: true
|
|
117
|
+
},
|
|
118
|
+
inputSize: {
|
|
119
|
+
type: String,
|
|
120
|
+
default: 'small'
|
|
121
|
+
},
|
|
122
|
+
showStops: {
|
|
123
|
+
type: Boolean,
|
|
124
|
+
default: false
|
|
125
|
+
},
|
|
126
|
+
showTooltip: {
|
|
127
|
+
type: Boolean,
|
|
128
|
+
default: true
|
|
129
|
+
},
|
|
130
|
+
formatTooltip: Function,
|
|
131
|
+
disabled: {
|
|
132
|
+
type: Boolean,
|
|
133
|
+
default: false
|
|
134
|
+
},
|
|
135
|
+
range: {
|
|
136
|
+
type: Boolean,
|
|
137
|
+
default: false
|
|
138
|
+
},
|
|
139
|
+
vertical: {
|
|
140
|
+
type: Boolean,
|
|
141
|
+
default: false
|
|
142
|
+
},
|
|
143
|
+
height: {
|
|
144
|
+
type: String
|
|
145
|
+
},
|
|
146
|
+
debounce: {
|
|
147
|
+
type: Number,
|
|
148
|
+
default: 300
|
|
149
|
+
},
|
|
150
|
+
label: {
|
|
151
|
+
type: String
|
|
152
|
+
},
|
|
153
|
+
tooltipClass: String,
|
|
154
|
+
marks: Object
|
|
155
|
+
},
|
|
156
|
+
|
|
157
|
+
components: {
|
|
158
|
+
ElInputNumber,
|
|
159
|
+
SliderButton,
|
|
160
|
+
SliderMarker
|
|
161
|
+
},
|
|
162
|
+
|
|
163
|
+
data() {
|
|
164
|
+
return {
|
|
165
|
+
firstValue: null,
|
|
166
|
+
secondValue: null,
|
|
167
|
+
oldValue: null,
|
|
168
|
+
dragging: false,
|
|
169
|
+
sliderSize: 1
|
|
170
|
+
};
|
|
171
|
+
},
|
|
172
|
+
|
|
173
|
+
watch: {
|
|
174
|
+
value(val, oldVal) {
|
|
175
|
+
if (this.dragging ||
|
|
176
|
+
Array.isArray(val) &&
|
|
177
|
+
Array.isArray(oldVal) &&
|
|
178
|
+
val.every((item, index) => item === oldVal[index])) {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
this.setValues();
|
|
182
|
+
},
|
|
183
|
+
|
|
184
|
+
dragging(val) {
|
|
185
|
+
if (!val) {
|
|
186
|
+
this.setValues();
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
|
|
190
|
+
firstValue(val) {
|
|
191
|
+
if (this.range) {
|
|
192
|
+
this.$emit('input', [this.minValue, this.maxValue]);
|
|
193
|
+
} else {
|
|
194
|
+
this.$emit('input', val);
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
|
|
198
|
+
secondValue() {
|
|
199
|
+
if (this.range) {
|
|
200
|
+
this.$emit('input', [this.minValue, this.maxValue]);
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
|
|
204
|
+
min() {
|
|
205
|
+
this.setValues();
|
|
206
|
+
},
|
|
207
|
+
|
|
208
|
+
max() {
|
|
209
|
+
this.setValues();
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
|
|
213
|
+
methods: {
|
|
214
|
+
valueChanged() {
|
|
215
|
+
if (this.range) {
|
|
216
|
+
return ![this.minValue, this.maxValue]
|
|
217
|
+
.every((item, index) => item === this.oldValue[index]);
|
|
218
|
+
} else {
|
|
219
|
+
return this.value !== this.oldValue;
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
setValues() {
|
|
223
|
+
if (this.min > this.max) {
|
|
224
|
+
console.error('[Element Error][Slider]min should not be greater than max.');
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
const val = this.value;
|
|
228
|
+
if (this.range && Array.isArray(val)) {
|
|
229
|
+
if (val[1] < this.min) {
|
|
230
|
+
this.$emit('input', [this.min, this.min]);
|
|
231
|
+
} else if (val[0] > this.max) {
|
|
232
|
+
this.$emit('input', [this.max, this.max]);
|
|
233
|
+
} else if (val[0] < this.min) {
|
|
234
|
+
this.$emit('input', [this.min, val[1]]);
|
|
235
|
+
} else if (val[1] > this.max) {
|
|
236
|
+
this.$emit('input', [val[0], this.max]);
|
|
237
|
+
} else {
|
|
238
|
+
this.firstValue = val[0];
|
|
239
|
+
this.secondValue = val[1];
|
|
240
|
+
if (this.valueChanged()) {
|
|
241
|
+
this.dispatch('ElFormItem', 'el.form.change', [this.minValue, this.maxValue]);
|
|
242
|
+
this.oldValue = val.slice();
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
} else if (!this.range && typeof val === 'number' && !isNaN(val)) {
|
|
246
|
+
if (val < this.min) {
|
|
247
|
+
this.$emit('input', this.min);
|
|
248
|
+
} else if (val > this.max) {
|
|
249
|
+
this.$emit('input', this.max);
|
|
250
|
+
} else {
|
|
251
|
+
this.firstValue = val;
|
|
252
|
+
if (this.valueChanged()) {
|
|
253
|
+
this.dispatch('ElFormItem', 'el.form.change', val);
|
|
254
|
+
this.oldValue = val;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
|
|
260
|
+
setPosition(percent) {
|
|
261
|
+
const targetValue = this.min + percent * (this.max - this.min) / 100;
|
|
262
|
+
if (!this.range) {
|
|
263
|
+
this.$refs.button1.setPosition(percent);
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
let button;
|
|
267
|
+
if (Math.abs(this.minValue - targetValue) < Math.abs(this.maxValue - targetValue)) {
|
|
268
|
+
button = this.firstValue < this.secondValue ? 'button1' : 'button2';
|
|
269
|
+
} else {
|
|
270
|
+
button = this.firstValue > this.secondValue ? 'button1' : 'button2';
|
|
271
|
+
}
|
|
272
|
+
this.$refs[button].setPosition(percent);
|
|
273
|
+
},
|
|
274
|
+
|
|
275
|
+
onSliderClick(event) {
|
|
276
|
+
if (this.sliderDisabled || this.dragging) return;
|
|
277
|
+
this.resetSize();
|
|
278
|
+
if (this.vertical) {
|
|
279
|
+
const sliderOffsetBottom = this.$refs.slider.getBoundingClientRect().bottom;
|
|
280
|
+
this.setPosition((sliderOffsetBottom - event.clientY) / this.sliderSize * 100);
|
|
281
|
+
} else {
|
|
282
|
+
const sliderOffsetLeft = this.$refs.slider.getBoundingClientRect().left;
|
|
283
|
+
this.setPosition((event.clientX - sliderOffsetLeft) / this.sliderSize * 100);
|
|
284
|
+
}
|
|
285
|
+
this.emitChange();
|
|
286
|
+
},
|
|
287
|
+
|
|
288
|
+
resetSize() {
|
|
289
|
+
if (this.$refs.slider) {
|
|
290
|
+
this.sliderSize = this.$refs.slider[`client${ this.vertical ? 'Height' : 'Width' }`];
|
|
291
|
+
}
|
|
292
|
+
},
|
|
293
|
+
|
|
294
|
+
emitChange() {
|
|
295
|
+
this.$nextTick(() => {
|
|
296
|
+
this.$emit('change', this.range ? [this.minValue, this.maxValue] : this.value);
|
|
297
|
+
});
|
|
298
|
+
},
|
|
299
|
+
|
|
300
|
+
getStopStyle(position) {
|
|
301
|
+
return this.vertical ? { 'bottom': position + '%' } : { 'left': position + '%' };
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
|
|
305
|
+
computed: {
|
|
306
|
+
stops() {
|
|
307
|
+
if (!this.showStops || this.min > this.max) return [];
|
|
308
|
+
if (this.step === 0) {
|
|
309
|
+
process.env.NODE_ENV !== 'production' &&
|
|
310
|
+
console.warn('[Element Warn][Slider]step should not be 0.');
|
|
311
|
+
return [];
|
|
312
|
+
}
|
|
313
|
+
const stopCount = (this.max - this.min) / this.step;
|
|
314
|
+
const stepWidth = 100 * this.step / (this.max - this.min);
|
|
315
|
+
const result = [];
|
|
316
|
+
for (let i = 1; i < stopCount; i++) {
|
|
317
|
+
result.push(i * stepWidth);
|
|
318
|
+
}
|
|
319
|
+
if (this.range) {
|
|
320
|
+
return result.filter(step => {
|
|
321
|
+
return step < 100 * (this.minValue - this.min) / (this.max - this.min) ||
|
|
322
|
+
step > 100 * (this.maxValue - this.min) / (this.max - this.min);
|
|
323
|
+
});
|
|
324
|
+
} else {
|
|
325
|
+
return result.filter(step => step > 100 * (this.firstValue - this.min) / (this.max - this.min));
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
|
|
329
|
+
markList() {
|
|
330
|
+
if (!this.marks) {
|
|
331
|
+
return [];
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
const marksKeys = Object.keys(this.marks);
|
|
335
|
+
return marksKeys.map(parseFloat)
|
|
336
|
+
.sort((a, b) => a - b)
|
|
337
|
+
.filter(point => point <= this.max && point >= this.min)
|
|
338
|
+
.map(point => ({
|
|
339
|
+
point,
|
|
340
|
+
position: (point - this.min) * 100 / (this.max - this.min),
|
|
341
|
+
mark: this.marks[point]
|
|
342
|
+
}));
|
|
343
|
+
},
|
|
344
|
+
|
|
345
|
+
minValue() {
|
|
346
|
+
return Math.min(this.firstValue, this.secondValue);
|
|
347
|
+
},
|
|
348
|
+
|
|
349
|
+
maxValue() {
|
|
350
|
+
return Math.max(this.firstValue, this.secondValue);
|
|
351
|
+
},
|
|
352
|
+
|
|
353
|
+
barSize() {
|
|
354
|
+
return this.range
|
|
355
|
+
? `${ 100 * (this.maxValue - this.minValue) / (this.max - this.min) }%`
|
|
356
|
+
: `${ 100 * (this.firstValue - this.min) / (this.max - this.min) }%`;
|
|
357
|
+
},
|
|
358
|
+
|
|
359
|
+
barStart() {
|
|
360
|
+
return this.range
|
|
361
|
+
? `${ 100 * (this.minValue - this.min) / (this.max - this.min) }%`
|
|
362
|
+
: '0%';
|
|
363
|
+
},
|
|
364
|
+
|
|
365
|
+
precision() {
|
|
366
|
+
let precisions = [this.min, this.max, this.step].map(item => {
|
|
367
|
+
let decimal = ('' + item).split('.')[1];
|
|
368
|
+
return decimal ? decimal.length : 0;
|
|
369
|
+
});
|
|
370
|
+
return Math.max.apply(null, precisions);
|
|
371
|
+
},
|
|
372
|
+
|
|
373
|
+
runwayStyle() {
|
|
374
|
+
return this.vertical ? { height: this.height } : {};
|
|
375
|
+
},
|
|
376
|
+
|
|
377
|
+
barStyle() {
|
|
378
|
+
return this.vertical
|
|
379
|
+
? {
|
|
380
|
+
height: this.barSize,
|
|
381
|
+
bottom: this.barStart
|
|
382
|
+
} : {
|
|
383
|
+
width: this.barSize,
|
|
384
|
+
left: this.barStart
|
|
385
|
+
};
|
|
386
|
+
},
|
|
387
|
+
|
|
388
|
+
sliderDisabled() {
|
|
389
|
+
return this.disabled || (this.elForm || {}).disabled;
|
|
390
|
+
}
|
|
391
|
+
},
|
|
392
|
+
|
|
393
|
+
mounted() {
|
|
394
|
+
let valuetext;
|
|
395
|
+
if (this.range) {
|
|
396
|
+
if (Array.isArray(this.value)) {
|
|
397
|
+
this.firstValue = Math.max(this.min, this.value[0]);
|
|
398
|
+
this.secondValue = Math.min(this.max, this.value[1]);
|
|
399
|
+
} else {
|
|
400
|
+
this.firstValue = this.min;
|
|
401
|
+
this.secondValue = this.max;
|
|
402
|
+
}
|
|
403
|
+
this.oldValue = [this.firstValue, this.secondValue];
|
|
404
|
+
valuetext = `${this.firstValue}-${this.secondValue}`;
|
|
405
|
+
} else {
|
|
406
|
+
if (typeof this.value !== 'number' || isNaN(this.value)) {
|
|
407
|
+
this.firstValue = this.min;
|
|
408
|
+
} else {
|
|
409
|
+
this.firstValue = Math.min(this.max, Math.max(this.min, this.value));
|
|
410
|
+
}
|
|
411
|
+
this.oldValue = this.firstValue;
|
|
412
|
+
valuetext = this.firstValue;
|
|
413
|
+
}
|
|
414
|
+
this.$el.setAttribute('aria-valuetext', valuetext);
|
|
415
|
+
|
|
416
|
+
// label screen reader
|
|
417
|
+
this.$el.setAttribute('aria-label', this.label ? this.label : `slider between ${this.min} and ${this.max}`);
|
|
418
|
+
|
|
419
|
+
this.resetSize();
|
|
420
|
+
window.addEventListener('resize', this.resetSize);
|
|
421
|
+
},
|
|
422
|
+
|
|
423
|
+
beforeDestroy() {
|
|
424
|
+
window.removeEventListener('resize', this.resetSize);
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
</script>
|