Skip to content

Commit a1f5942

Browse files
committed
chore: popup 隐藏时,mask不阻挡点击
1 parent 962688c commit a1f5942

File tree

5 files changed

+45
-20
lines changed

5 files changed

+45
-20
lines changed

packages/mpx-cube-ui/lib/components/popup/index.mpx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
wx:class="{{ [themeType ? 'cube-popup cube-popup-'+themeType : 'cube-popup', rootClass, visibleClass] }}"
66
wx:style="{{ popupStyle }}"
77
>
8-
<view class="cube-popup-mask" wx:if="{{ mask }}" bindtouchend="onMaskClick" wx:style="{{ [styleConfig.mask, maskOpacity] }}">
8+
<view class="cube-popup-mask" wx:if="{{ mask }}" bindtouchend="onMaskClick" wx:style="{{ [styleConfig.mask, maskStyle] }}">
99
<!-- 遮罩插槽 -->
1010
<slot name="mask"></slot>
1111
</view>
@@ -30,7 +30,7 @@
3030
<view
3131
class="cube-popup-mask"
3232
wx:if="{{ mask }}"
33-
wx:style="{{ [styleConfig.mask, maskOpacity] }}"
33+
wx:style="{{ [styleConfig.mask, maskStyle] }}"
3434
bindtouchmove="preventTouchMove"
3535
bindtouchend="onMaskClick">
3636
<!-- 遮罩插槽 -->
@@ -57,7 +57,7 @@
5757
<view
5858
class="cube-popup-mask"
5959
wx:if="{{ mask }}"
60-
wx:style="{{ styleConfig.mask }}"
60+
wx:style="{{ [styleConfig.mask, maskStyle] }}"
6161
animation="{{ maskAnimationData }}"
6262
bindtouchend="onMaskClick">
6363
<slot name="mask"></slot>

packages/mpx-cube-ui/lib/components/popup/popup.js

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ createComponent({
7070
if (this.pointerEvents) {
7171
style.pointerEvents = this.pointerEvents;
7272
}
73+
if (!this.isVisible) {
74+
if (__mpx_mode__ === 'ios' || __mpx_mode__ === 'android') {
75+
style.pointerEvents = 'box-none';
76+
}
77+
else {
78+
style.pointerEvents = 'none';
79+
}
80+
}
7381
return style;
7482
},
7583
rootClass() {
@@ -94,18 +102,23 @@ createComponent({
94102
}
95103
return cls;
96104
},
97-
maskOpacity() {
98-
// eslint-disable-next-line
99-
// @ts-ignore
105+
maskStyle() {
106+
const style = {};
100107
if (__mpx_mode__ !== 'ios' &&
101108
__mpx_mode__ !== 'android' &&
102109
this.styleConfig.mask?.visibleOpacity &&
103110
this.isVisible) {
104-
return {
105-
opacity: this.styleConfig.mask.visibleOpacity
106-
};
111+
style.opacity = this.styleConfig.mask.visibleOpacity;
112+
}
113+
if (!this.isVisible) {
114+
if (__mpx_mode__ === 'ios' || __mpx_mode__ === 'android') {
115+
style.pointerEvents = 'box-none';
116+
}
117+
else {
118+
style.pointerEvents = 'none';
119+
}
107120
}
108-
return {};
121+
return style;
109122
}
110123
},
111124
methods: {

packages/mpx-cube-ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@mpxjs/mpx-cube-ui",
3-
"version": "1.3.12",
3+
"version": "1.3.14-beta.2",
44
"description": "mpx components library",
55
"author": "xiaolei <[email protected]>",
66
"publishConfig": {

packages/mpx-cube-ui/src/components/popup/index.mpx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
wx:class="{{ [themeType ? 'cube-popup cube-popup-'+themeType : 'cube-popup', rootClass, visibleClass] }}"
66
wx:style="{{ popupStyle }}"
77
>
8-
<view class="cube-popup-mask" wx:if="{{ mask }}" bindtouchend="onMaskClick" wx:style="{{ [styleConfig.mask, maskOpacity] }}">
8+
<view class="cube-popup-mask" wx:if="{{ mask }}" bindtouchend="onMaskClick" wx:style="{{ [styleConfig.mask, maskStyle] }}">
99
<!-- 遮罩插槽 -->
1010
<slot name="mask"></slot>
1111
</view>
@@ -30,7 +30,7 @@
3030
<view
3131
class="cube-popup-mask"
3232
wx:if="{{ mask }}"
33-
wx:style="{{ [styleConfig.mask, maskOpacity] }}"
33+
wx:style="{{ [styleConfig.mask, maskStyle] }}"
3434
bindtouchmove="preventTouchMove"
3535
bindtouchend="onMaskClick">
3636
<!-- 遮罩插槽 -->
@@ -57,7 +57,7 @@
5757
<view
5858
class="cube-popup-mask"
5959
wx:if="{{ mask }}"
60-
wx:style="{{ styleConfig.mask }}"
60+
wx:style="{{ [styleConfig.mask, maskStyle] }}"
6161
animation="{{ maskAnimationData }}"
6262
bindtouchend="onMaskClick">
6363
<slot name="mask"></slot>

packages/mpx-cube-ui/src/components/popup/popup.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ createComponent({
7676
if (this.pointerEvents) {
7777
style.pointerEvents = this.pointerEvents
7878
}
79+
if (!this.isVisible) {
80+
if (__mpx_mode__ === 'ios' || __mpx_mode__ === 'android') {
81+
style.pointerEvents = 'box-none'
82+
} else {
83+
style.pointerEvents = 'none'
84+
}
85+
}
7986
return style
8087
},
8188
rootClass() {
@@ -99,20 +106,25 @@ createComponent({
99106
}
100107
return cls
101108
},
102-
maskOpacity() {
103-
// eslint-disable-next-line
104-
// @ts-ignore
109+
maskStyle() {
110+
const style: Record<string, string> = {}
105111
if (
106112
__mpx_mode__ !== 'ios' &&
107113
__mpx_mode__ !== 'android' &&
108114
this.styleConfig.mask?.visibleOpacity &&
109115
this.isVisible
110116
) {
111-
return {
112-
opacity: this.styleConfig.mask.visibleOpacity
117+
style.opacity = this.styleConfig.mask.visibleOpacity
118+
}
119+
120+
if (!this.isVisible) {
121+
if (__mpx_mode__ === 'ios' || __mpx_mode__ === 'android') {
122+
style.pointerEvents = 'box-none'
123+
} else {
124+
style.pointerEvents = 'none'
113125
}
114126
}
115-
return {}
127+
return style
116128
}
117129
},
118130
methods: {

0 commit comments

Comments
 (0)