Commit 5709f32ede52ff4a7582fe2352e195cc6ec1c4cc

Authored by 梁灏
1 parent 41d90ccf

Slider support hidden Tooltip when tip-format return null

Slider support hidden Tooltip when tip-format return null
Showing 2 changed files with 10 additions and 17 deletions   Show diff stats
src/components/slider/slider.vue
@@ -8,17 +8,17 @@ @@ -8,17 +8,17 @@
8 :value="value" 8 :value="value"
9 :disabled="disabled" 9 :disabled="disabled"
10 @on-change="handleInputChange"></Input-number> 10 @on-change="handleInputChange"></Input-number>
11 - <div :class="[prefixCls + '-wrap']" v-el:slider @click="sliderClick"> 11 + <div :class="[prefixCls + '-wrap']" v-el:slider @click.self="sliderClick">
12 <template v-if="showStops"> 12 <template v-if="showStops">
13 - <div :class="[prefixCls + '-stop']" v-for="item in stops" :style="{ 'left': item + '%' }"></div> 13 + <div :class="[prefixCls + '-stop']" v-for="item in stops" :style="{ 'left': item + '%' }" @click.self="sliderClick"></div>
14 </template> 14 </template>
15 - <div :class="[prefixCls + '-bar']" :style="barStyle"></div> 15 + <div :class="[prefixCls + '-bar']" :style="barStyle" @click.self="sliderClick"></div>
16 <template v-if="range"> 16 <template v-if="range">
17 <div 17 <div
18 :class="[prefixCls + '-button-wrap']" 18 :class="[prefixCls + '-button-wrap']"
19 :style="{left: firstPosition + '%'}" 19 :style="{left: firstPosition + '%'}"
20 @mousedown="onFirstButtonDown"> 20 @mousedown="onFirstButtonDown">
21 - <Tooltip placement="top" :content="tipFormat(value[0])" v-ref:tooltip> 21 + <Tooltip placement="top" :content="tipFormat(value[0])" :disabled="tipFormat(value[0]) === null" v-ref:tooltip>
22 <div :class="button1Classes"></div> 22 <div :class="button1Classes"></div>
23 </Tooltip> 23 </Tooltip>
24 </div> 24 </div>
@@ -26,7 +26,7 @@ @@ -26,7 +26,7 @@
26 :class="[prefixCls + '-button-wrap']" 26 :class="[prefixCls + '-button-wrap']"
27 :style="{left: secondPosition + '%'}" 27 :style="{left: secondPosition + '%'}"
28 @mousedown="onSecondButtonDown"> 28 @mousedown="onSecondButtonDown">
29 - <Tooltip placement="top" :content="tipFormat(value[1])" v-ref:tooltip2> 29 + <Tooltip placement="top" :content="tipFormat(value[1])" :disabled="tipFormat(value[1]) === null" v-ref:tooltip2>
30 <div :class="button2Classes"></div> 30 <div :class="button2Classes"></div>
31 </Tooltip> 31 </Tooltip>
32 </div> 32 </div>
@@ -36,7 +36,7 @@ @@ -36,7 +36,7 @@
36 :class="[prefixCls + '-button-wrap']" 36 :class="[prefixCls + '-button-wrap']"
37 :style="{left: singlePosition + '%'}" 37 :style="{left: singlePosition + '%'}"
38 @mousedown="onSingleButtonDown"> 38 @mousedown="onSingleButtonDown">
39 - <Tooltip placement="top" :content="tipFormat(value)" v-ref:tooltip> 39 + <Tooltip placement="top" :content="tipFormat(value)" :disabled="tipFormat(value) === null" v-ref:tooltip>
40 <div :class="buttonClasses"></div> 40 <div :class="buttonClasses"></div>
41 </Tooltip> 41 </Tooltip>
42 </div> 42 </div>
@@ -163,15 +163,6 @@ @@ -163,15 +163,6 @@
163 return style; 163 return style;
164 }, 164 },
165 stops() { 165 stops() {
166 -// let stopCount = (this.max - this.value) / this.step;  
167 -// let result = [];  
168 -// let currentLeft = parseFloat(this.singlePosition);  
169 -// let stepWidth = 100 * this.step / (this.max - this.min);  
170 -// for (let i = 1; i < stopCount; i++) {  
171 -// result.push(currentLeft + i * stepWidth);  
172 -// }  
173 -// return result;  
174 -  
175 let stopCount = (this.max - this.min) / this.step; 166 let stopCount = (this.max - this.min) / this.step;
176 let result = []; 167 let result = [];
177 let stepWidth = 100 * this.step / (this.max - this.min); 168 let stepWidth = 100 * this.step / (this.max - this.min);
test/routers/slider.vue
1 <template> 1 <template>
2 <div style="width: 400px;margin:100px;"> 2 <div style="width: 400px;margin:100px;">
3 {{ value }} 3 {{ value }}
4 - <Slider @on-change="change" :step="10" show-stops></Slider> 4 + <Slider @on-change="change"></Slider>
  5 + <Slider :value="40" :tip-format="format"></Slider>
5 <Slider :value.sync="value" show-input show-stops range @on-change="change" :step="13"></Slider> 6 <Slider :value.sync="value" show-input show-stops range @on-change="change" :step="13"></Slider>
6 <!--<Slider :max="10"></Slider>--> 7 <!--<Slider :max="10"></Slider>-->
7 <!--<Slider :step="13"></Slider>--> 8 <!--<Slider :step="13"></Slider>-->
@@ -19,10 +20,11 @@ @@ -19,10 +20,11 @@
19 }, 20 },
20 methods: { 21 methods: {
21 format (val) { 22 format (val) {
  23 + return null;
22 return `进度:${val}%` 24 return `进度:${val}%`
23 }, 25 },
24 change (data) { 26 change (data) {
25 - console.log(data) 27 +// console.log(data)
26 } 28 }
27 } 29 }
28 } 30 }