Commit 5709f32ede52ff4a7582fe2352e195cc6ec1c4cc
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 | 8 | :value="value" |
| 9 | 9 | :disabled="disabled" |
| 10 | 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 | 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 | 14 | </template> |
| 15 | - <div :class="[prefixCls + '-bar']" :style="barStyle"></div> | |
| 15 | + <div :class="[prefixCls + '-bar']" :style="barStyle" @click.self="sliderClick"></div> | |
| 16 | 16 | <template v-if="range"> |
| 17 | 17 | <div |
| 18 | 18 | :class="[prefixCls + '-button-wrap']" |
| 19 | 19 | :style="{left: firstPosition + '%'}" |
| 20 | 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 | 22 | <div :class="button1Classes"></div> |
| 23 | 23 | </Tooltip> |
| 24 | 24 | </div> |
| ... | ... | @@ -26,7 +26,7 @@ |
| 26 | 26 | :class="[prefixCls + '-button-wrap']" |
| 27 | 27 | :style="{left: secondPosition + '%'}" |
| 28 | 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 | 30 | <div :class="button2Classes"></div> |
| 31 | 31 | </Tooltip> |
| 32 | 32 | </div> |
| ... | ... | @@ -36,7 +36,7 @@ |
| 36 | 36 | :class="[prefixCls + '-button-wrap']" |
| 37 | 37 | :style="{left: singlePosition + '%'}" |
| 38 | 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 | 40 | <div :class="buttonClasses"></div> |
| 41 | 41 | </Tooltip> |
| 42 | 42 | </div> |
| ... | ... | @@ -163,15 +163,6 @@ |
| 163 | 163 | return style; |
| 164 | 164 | }, |
| 165 | 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 | 166 | let stopCount = (this.max - this.min) / this.step; |
| 176 | 167 | let result = []; |
| 177 | 168 | let stepWidth = 100 * this.step / (this.max - this.min); | ... | ... |
test/routers/slider.vue
| 1 | 1 | <template> |
| 2 | 2 | <div style="width: 400px;margin:100px;"> |
| 3 | 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 | 6 | <Slider :value.sync="value" show-input show-stops range @on-change="change" :step="13"></Slider> |
| 6 | 7 | <!--<Slider :max="10"></Slider>--> |
| 7 | 8 | <!--<Slider :step="13"></Slider>--> |
| ... | ... | @@ -19,10 +20,11 @@ |
| 19 | 20 | }, |
| 20 | 21 | methods: { |
| 21 | 22 | format (val) { |
| 23 | + return null; | |
| 22 | 24 | return `进度:${val}%` |
| 23 | 25 | }, |
| 24 | 26 | change (data) { |
| 25 | - console.log(data) | |
| 27 | +// console.log(data) | |
| 26 | 28 | } |
| 27 | 29 | } |
| 28 | 30 | } | ... | ... |