diff --git a/src/rate/README.md b/src/rate/README.md index 1649039bd..08364efc5 100644 --- a/src/rate/README.md +++ b/src/rate/README.md @@ -100,12 +100,13 @@ export default { | gutter | Icon gutter | *string \| number* | `4px` | - | | color | Selected color | *string* | `#ffd21e` | - | | void-color | Void color | *string* | `#c7c7c7` | - | +| disabled-color | Disabled color | *string* | `#bdbdbd` | - | | icon | Selected icon | *string* | `star` | - | | void-icon | Void icon | *string* | `star-o` | - | | allow-half | Whether to allow half star | *boolean* | `false` | - | | readonly | Whether to be readonly | *boolean* | `false` | - | | disabled | Whether to disable rate | *boolean* | `false` | - | -| disabled-color | Disabled color | *string* | `#bdbdbd` | - | +| touchable | Whether to allow select rate by touch gesture | *boolean* | `true` | 2.2.0 | ### Events diff --git a/src/rate/README.zh-CN.md b/src/rate/README.zh-CN.md index e7de8b5e7..3253af28e 100644 --- a/src/rate/README.zh-CN.md +++ b/src/rate/README.zh-CN.md @@ -100,12 +100,13 @@ export default { | gutter | 图标间距,默认单位为`px` | *string \| number* | `4px` | - | | color | 选中时的颜色 | *string* | `#ffd21e` | - | | void-color | 未选中时的颜色 | *string* | `#c7c7c7` | - | +| disabled-color | 禁用时的颜色 | *string* | `#bdbdbd` | - | | icon | 选中时的图标名称或图片链接,可选值见 Icon 组件 | *string* | `star` | - | | void-icon | 未选中时的图标名称或图片链接,可选值见 Icon 组件 | *string* | `star-o` | - | | allow-half | 是否允许半选 | *boolean* | `false` | - | | readonly | 是否为只读状态 | *boolean* | `false` | - | | disabled | 是否禁用评分 | *boolean* | `false` | - | -| disabled-color | 禁用时的颜色 | *string* | `#bdbdbd` | - | +| touchable | 是否可以通过滑动手势选择评分 | *boolean* | `true` | 2.2.0 | ### Events diff --git a/src/rate/index.js b/src/rate/index.js index 4430683ea..dd88912e7 100644 --- a/src/rate/index.js +++ b/src/rate/index.js @@ -53,6 +53,10 @@ export default createComponent({ count: { type: Number, default: 5 + }, + touchable: { + type: Boolean, + default: true } }, @@ -84,7 +88,7 @@ export default createComponent({ }, onTouchStart(event) { - if (this.readonly || this.disabled) { + if (this.readonly || this.disabled || !this.touchable) { return; } @@ -108,7 +112,7 @@ export default createComponent({ }, onTouchMove(event) { - if (this.readonly || this.disabled) { + if (this.readonly || this.disabled || !this.touchable) { return; } diff --git a/src/rate/test/index.spec.js b/src/rate/test/index.spec.js index b55315c31..9b20ca337 100644 --- a/src/rate/test/index.spec.js +++ b/src/rate/test/index.spec.js @@ -137,3 +137,18 @@ test('size prop', () => { expect(wrapper).toMatchSnapshot(); }); + +test('untouchable', () => { + const onChange = jest.fn(); + const wrapper = mount(Rate, { + propsData: { + touchable: false + }, + listeners: { + change: onChange + } + }); + + triggerDrag(wrapper, 100, 0); + expect(onChange).toHaveBeenCalledTimes(0); +}); diff --git a/src/swipe/README.md b/src/swipe/README.md index 7f46b7413..58866c063 100644 --- a/src/swipe/README.md +++ b/src/swipe/README.md @@ -132,7 +132,7 @@ export default { | duration | Animation duration (ms) | *number* | `500` | - | | loop | Whether to enable loop | *boolean* | `true` | - | | vertical | Vertical Scrolling | *boolean* | `false` | - | -| touchable | Whether touchable | *boolean* | `true` | - | +| 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` | - |