From 33c11facffe76e8a37e09f7eaff2626c70541ef8 Mon Sep 17 00:00:00 2001 From: Lindy <33708359+Lindysen@users.noreply.github.com> Date: Sun, 19 Jan 2020 20:23:05 +0800 Subject: [PATCH] feat(Stepper): add disable-long-press feature (#2691) * feat(Stepper): add disable-long-press feature * feat(Stepper): name the same as Vant --- example/pages/stepper/index.wxml | 4 ++++ example/project.config.json | 2 +- packages/stepper/README.md | 9 +++++++++ packages/stepper/index.ts | 12 +++++++++++- 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/example/pages/stepper/index.wxml b/example/pages/stepper/index.wxml index cc0e59a9..417bd361 100644 --- a/example/pages/stepper/index.wxml +++ b/example/pages/stepper/index.wxml @@ -18,6 +18,10 @@ + + + + diff --git a/example/project.config.json b/example/project.config.json index f8cebc50..303f0f39 100644 --- a/example/project.config.json +++ b/example/project.config.json @@ -339,4 +339,4 @@ ] } } -} +} \ No newline at end of file diff --git a/packages/stepper/README.md b/packages/stepper/README.md index 0123dc4f..fc063d0e 100644 --- a/packages/stepper/README.md +++ b/packages/stepper/README.md @@ -64,6 +64,14 @@ Page({ ``` +### 关闭长按 + +通过设置`long-press`属性决定步进器是否开启长按手势 + +```html + +``` + ### 固定小数位数 通过设置`decimal-length`属性可以保留固定的小数位数 @@ -127,6 +135,7 @@ Page({ | decimal-length | 固定显示的小数位数 | *number* | - | - | | disable-plus | 是否禁用增加按钮 | *boolean* | - | - | | disable-minus | 是否禁用减少按钮 | *boolean* | - | - | +| long-press | 是否开启长按手势 | *boolean* | `true` | - | ### Events diff --git a/packages/stepper/index.ts b/packages/stepper/index.ts index ebd67c59..c9ec2f4d 100644 --- a/packages/stepper/index.ts +++ b/packages/stepper/index.ts @@ -77,7 +77,11 @@ VantComponent({ value: true }, disablePlus: Boolean, - disableMinus: Boolean + disableMinus: Boolean, + longPress: { + type: Boolean, + value: true + }, }, data: { @@ -160,6 +164,9 @@ VantComponent({ }, onTouchStart(event: Weapp.Event) { + if (!this.data.longPress) { + return; + } clearTimeout(this.longPressTimer); const { type } = event.currentTarget.dataset; @@ -174,6 +181,9 @@ VantComponent({ }, onTouchEnd() { + if (!this.data.longPress) { + return; + } clearTimeout(this.longPressTimer); },