From aa0dfe8808be5eeb4e3bd3ff26adccf9c8313e40 Mon Sep 17 00:00:00 2001 From: neverland Date: Sat, 9 Nov 2019 21:32:04 +0800 Subject: [PATCH] feat(Swipe): add stop-propagation prop (#4972) --- src/swipe/README.md | 11 ++++++----- src/swipe/README.zh-CN.md | 5 +++-- src/swipe/index.js | 6 +++++- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/swipe/README.md b/src/swipe/README.md index 64d3c89a1..e1caa88c1 100644 --- a/src/swipe/README.md +++ b/src/swipe/README.md @@ -130,14 +130,15 @@ export default { |------|------|------|------|------| | autoplay | Autoplay interval (ms) | *number* | - | - | | duration | Animation duration (ms) | *number* | `500` | - | -| loop | Whether to enable loop | *boolean* | `true` | - | -| vertical | Vertical Scrolling | *boolean* | `false` | - | -| touchable | Whether to allow swipe by touch gesture | *boolean* | `true` | - | -| show-indicators | Whether to show indicators | *boolean* | `true` | - | -| indicator-color | Indicator color | *string* | `#1989fa` | - | | initial-swipe | Index of initial swipe, start from 0 | *number* | `0` | - | | width | Set Swiper Item Width | *number* | `0` | - | | height | Set Swiper Item Height | *number* | `0` | - | +| loop | Whether to enable loop | *boolean* | `true` | - | +| show-indicators | Whether to show indicators | *boolean* | `true` | - | +| indicator-color | Indicator color | *string* | `#1989fa` | - | +| vertical | Whether to be vertical Scrolling | *boolean* | `false` | - | +| touchable | Whether to allow swipe by touch gesture | *boolean* | `true` | - | +| stop-propagation | Whether to stop touchmove event propagation | *boolean* | `false` | 2.1.0 | ### Swipe Events diff --git a/src/swipe/README.zh-CN.md b/src/swipe/README.zh-CN.md index e9412a8a2..925bee4cb 100644 --- a/src/swipe/README.zh-CN.md +++ b/src/swipe/README.zh-CN.md @@ -137,13 +137,14 @@ export default { | autoplay | 自动轮播间隔,单位为 ms | *number* | - | - | | duration | 动画时长,单位为 ms | *number* | `500` | - | | initial-swipe | 初始位置索引值 | *number* | `0` | - | +| width | 滑块宽度 | *number* | `auto` | - | +| height | 滑块高度 | *number* | `auto` | - | | loop | 是否开启循环播放 | *boolean* | `true` | - | | show-indicators | 是否显示指示器 | *boolean* | `true` | - | | indicator-color | 指示器颜色 | *string* | `#1989fa` | - | | vertical | 是否为纵向滚动 | *boolean* | `false` | - | | touchable | 是否可以通过手势滑动 | *boolean* | `true` | - | -| width | 滑块宽度 | *number* | `auto` | - | -| height | 滑块高度 | *number* | `auto` | - | +| stop-propagation | 是否阻止滑动事件冒泡 | *boolean* | `true` | 2.2.13 | ### Swipe Events diff --git a/src/swipe/index.js b/src/swipe/index.js index ff5499fb8..5d076f5a6 100644 --- a/src/swipe/index.js +++ b/src/swipe/index.js @@ -46,6 +46,10 @@ export default createComponent({ showIndicators: { type: Boolean, default: true + }, + stopPropagation: { + type: Boolean, + default: true } }, @@ -169,7 +173,7 @@ export default createComponent({ this.touchMove(event); if (this.isCorrectDirection) { - preventDefault(event, true); + preventDefault(event, this.stopPropagation); this.move({ offset: this.delta }); } },