feat(ActionSheet): add close-on-click-action prop (#1995)

This commit is contained in:
君寻 2019-09-09 16:11:55 +08:00 committed by neverland
parent bbd601168c
commit fd82af0ac1
5 changed files with 16 additions and 7 deletions

View File

@ -1,4 +1,5 @@
import Page from '../../common/page';
const format = rate => Math.min(Math.max(rate, 0), 100);
Page({

View File

@ -94,6 +94,7 @@ Page({
| cancel-text | 取消按钮文字 | *string* | - | - |
| overlay | 是否显示遮罩层 | *boolean* | - | - |
| close-on-click-overlay | 点击遮罩是否关闭菜单 | *boolean* | - | - |
| close-on-click-action | 是否在点击选项后关闭 | *boolean* | `true` | - |
| safe-area-inset-bottom | 是否为 iPhoneX 留出底部安全距离 | *boolean* | `true` | - |
### Events

View File

@ -24,6 +24,10 @@ VantComponent({
closeOnClickOverlay: {
type: Boolean,
value: true
},
closeOnClickAction: {
type: Boolean,
value: true
}
},
@ -33,6 +37,10 @@ VantComponent({
const item = this.data.actions[index];
if (item && !item.disabled && !item.loading) {
this.$emit('select', item);
if (this.data.closeOnClickAction) {
this.onClose();
}
}
},

View File

@ -7,10 +7,10 @@
&__text {
position: absolute;
color: @circle-text-color;
top: 50%;
left: 0;
width: 100%;
color: @circle-text-color;
transform: translateY(-50%);
}
}

View File

@ -57,9 +57,10 @@ VantComponent({
methods: {
getContext() {
return (
this.ctx || (this.ctx = wx.createCanvasContext('van-circle', this))
);
if (this.ctx) {
return this.ctx;
}
this.ctx = wx.createCanvasContext('van-circle', this);
},
setHoverColor() {
@ -71,9 +72,7 @@ VantComponent({
const LinearColor = context.createLinearGradient(size, 0, 0, 0);
Object.keys(color)
.sort((a, b) => parseFloat(a) - parseFloat(b))
.map(key => {
LinearColor.addColorStop(parseFloat(key) / 100, color[key]);
});
.map(key => LinearColor.addColorStop(parseFloat(key) / 100, color[key]));
hoverColor = LinearColor;
}