From d6663464c913bf43a9b703df0fbb501cfc662952 Mon Sep 17 00:00:00 2001 From: neverland Date: Wed, 7 Jul 2021 16:29:21 +0800 Subject: [PATCH] feat(Slider): add drag event param (#8990) --- src/slider/README.md | 10 +++++----- src/slider/README.zh-CN.md | 18 +++++++++--------- src/slider/Slider.tsx | 6 +++--- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/slider/README.md b/src/slider/README.md index ef2b2a03b..94ef34571 100644 --- a/src/slider/README.md +++ b/src/slider/README.md @@ -150,7 +150,7 @@ export default { | Attribute | Description | Type | Default | | --- | --- | --- | --- | -| v-model | Current value | _number \| number[]_ | `0` | +| v-model | Current value | _number \| [number, number]_ | `0` | | max | Max value | _number \| string_ | `100` | | min | Min value | _number \| string_ | `0` | | step | Step size | _number \| string_ | `1` | @@ -167,10 +167,10 @@ export default { | Event | Description | Arguments | | ------------------ | ------------------------------ | ------------------- | -| update:model-value | Emitted when value is changing | value: current rate | -| change | Emitted after value changed | value: current rate | -| drag-start | Emitted when start draging | - | -| drag-end | Emitted when end draging | - | +| update:model-value | Emitted when value is changing | _value: number_ | +| change | Emitted after value changed | _value: number_ | +| drag-start | Emitted when start draging | _event: TouchEvent_ | +| drag-end | Emitted when end draging | _event: TouchEvent_ | ### Slots diff --git a/src/slider/README.zh-CN.md b/src/slider/README.zh-CN.md index 3c675a388..f069e0dc7 100644 --- a/src/slider/README.zh-CN.md +++ b/src/slider/README.zh-CN.md @@ -152,12 +152,12 @@ export default { | 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | -| v-model | 当前进度百分比 | _number \| number[]_ | `0` | +| v-model | 当前进度百分比,在双滑块模式下为数组格式 | _number \| [number, number]_ | `0` | | max | 最大值 | _number \| string_ | `100` | | min | 最小值 | _number \| string_ | `0` | | step | 步长 | _number \| string_ | `1` | -| bar-height | 进度条高度,默认单位为`px` | _number \| string_ | `2px` | -| button-size | 滑块按钮大小,默认单位为`px` | _number \| string_ | `24px` | +| bar-height | 进度条高度,默认单位为 `px` | _number \| string_ | `2px` | +| button-size | 滑块按钮大小,默认单位为 `px` | _number \| string_ | `24px` | | active-color | 进度条激活态颜色 | _string_ | `#1989fa` | | inactive-color | 进度条非激活态颜色 | _string_ | `#e5e5e5` | | range | 是否开启双滑块模式 | _boolean_ | `false` | @@ -167,12 +167,12 @@ export default { ### Events -| 事件名 | 说明 | 回调参数 | -| ------------------ | ------------------------ | --------------- | -| update:model-value | 进度变化时实时触发 | value: 当前进度 | -| change | 进度变化且结束拖动后触发 | value: 当前进度 | -| drag-start | 开始拖动时触发 | - | -| drag-end | 结束拖动时触发 | - | +| 事件名 | 说明 | 回调参数 | +| ------------------ | ------------------------ | ------------------- | +| update:model-value | 进度变化时实时触发 | _value: number_ | +| change | 进度变化且结束拖动后触发 | _value: number_ | +| drag-start | 开始拖动时触发 | _event: TouchEvent_ | +| drag-end | 结束拖动时触发 | _event: TouchEvent_ | ### Slots diff --git a/src/slider/Slider.tsx b/src/slider/Slider.tsx index a50c2246f..fbc4cda1f 100644 --- a/src/slider/Slider.tsx +++ b/src/slider/Slider.tsx @@ -192,7 +192,7 @@ export default defineComponent({ } if (dragStatus.value === 'start') { - emit('drag-start'); + emit('drag-start', event); } preventDefault(event, true); @@ -213,14 +213,14 @@ export default defineComponent({ updateValue(currentValue); }; - const onTouchEnd = () => { + const onTouchEnd = (event: TouchEvent) => { if (props.disabled || props.readonly) { return; } if (dragStatus.value === 'draging') { updateValue(currentValue, true); - emit('drag-end'); + emit('drag-end', event); } dragStatus.value = '';