mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-05 19:41:45 +08:00
fix(Slider): fix click invalid with vertical props (#4532)
* fix(Slider): fix click invalid with vertical props * fix: adjust demo
This commit is contained in:
parent
231f65b1a2
commit
91f44798a5
@ -67,7 +67,7 @@
|
||||
<demo-block title="垂直方向">
|
||||
<view style="height: 150px; padding-left: 30px;">
|
||||
<van-slider
|
||||
value="{{ currentValue }}"
|
||||
value="{{ 50 }}"
|
||||
vertical
|
||||
custom-class="slider"
|
||||
bind:change="onChange"
|
||||
|
@ -109,9 +109,10 @@ VantComponent({
|
||||
|
||||
getRect(this, '.van-slider').then((rect) => {
|
||||
const { vertical } = this.data;
|
||||
const touch = event.touches[0];
|
||||
const delta = vertical
|
||||
? event.detail.y - rect.top
|
||||
: event.detail.x - rect.left;
|
||||
? touch.clientY - rect.top
|
||||
: touch.clientX - rect.left;
|
||||
const total = vertical ? rect.height : rect.width;
|
||||
const value = Number(min) + (delta / total) * this.getRange();
|
||||
|
||||
@ -160,7 +161,7 @@ VantComponent({
|
||||
this.setData({
|
||||
wrapperStyle: `
|
||||
background: ${this.data.inactiveColor || ''};
|
||||
${mainAxis}: ${addUnit(this.data.barHeight) || ''};
|
||||
${vertical ? 'width' : 'height'}: ${addUnit(this.data.barHeight) || ''};
|
||||
`,
|
||||
barStyle: `
|
||||
${mainAxis}: ${this.calcMainAxis()};
|
||||
|
Loading…
x
Reference in New Issue
Block a user