mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
feat(Slider): add dragStart&dragEnd events (#2059)
This commit is contained in:
parent
810f20ea2e
commit
6206d7bda5
@ -104,6 +104,8 @@ Page({
|
|||||||
|-----------|-----------|-----------|
|
|-----------|-----------|-----------|
|
||||||
| bind:drag | 拖动进度条时触发 | event.detail.value: 当前进度 |
|
| bind:drag | 拖动进度条时触发 | event.detail.value: 当前进度 |
|
||||||
| bind:change | 进度值改变后触发 | event.detail: 当前进度 |
|
| bind:change | 进度值改变后触发 | event.detail: 当前进度 |
|
||||||
|
| bind:drag-start | 开始拖动时触发 | - |
|
||||||
|
| bind:drag-end | 结束拖动时触发 | - |
|
||||||
|
|
||||||
### 外部样式类
|
### 外部样式类
|
||||||
|
|
||||||
|
@ -49,12 +49,19 @@ VantComponent({
|
|||||||
|
|
||||||
this.touchStart(event);
|
this.touchStart(event);
|
||||||
this.startValue = this.format(this.data.value);
|
this.startValue = this.format(this.data.value);
|
||||||
|
this.dragStatus = 'start';
|
||||||
},
|
},
|
||||||
|
|
||||||
onTouchMove(event: Weapp.TouchEvent) {
|
onTouchMove(event: Weapp.TouchEvent) {
|
||||||
if (this.data.disabled) return;
|
if (this.data.disabled) return;
|
||||||
|
|
||||||
|
if (this.dragStatus === 'start') {
|
||||||
|
this.$emit('drag-start');
|
||||||
|
}
|
||||||
|
|
||||||
this.touchMove(event);
|
this.touchMove(event);
|
||||||
|
this.dragStatus = 'draging';
|
||||||
|
|
||||||
this.getRect('.van-slider').then((rect: WechatMiniprogram.BoundingClientRectCallbackResult) => {
|
this.getRect('.van-slider').then((rect: WechatMiniprogram.BoundingClientRectCallbackResult) => {
|
||||||
const diff = this.deltaX / rect.width * 100;
|
const diff = this.deltaX / rect.width * 100;
|
||||||
this.newValue = this.startValue + diff;
|
this.newValue = this.startValue + diff;
|
||||||
@ -64,7 +71,11 @@ VantComponent({
|
|||||||
|
|
||||||
onTouchEnd() {
|
onTouchEnd() {
|
||||||
if (this.data.disabled) return;
|
if (this.data.disabled) return;
|
||||||
this.updateValue(this.newValue, true);
|
|
||||||
|
if (this.dragStatus === 'draging') {
|
||||||
|
this.updateValue(this.newValue, true);
|
||||||
|
this.$emit('drag-end');
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onClick(event: Weapp.TouchEvent) {
|
onClick(event: Weapp.TouchEvent) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user