mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
feat(popup): add root-portal prop support (#5254)
* feat(popup): add root-portal prop support * fix(popup): fix test case error --------- Co-authored-by: liuhaihonggia <liuhaihong@youzan.com>
This commit is contained in:
parent
9352b33673
commit
17b9eadcb0
@ -55,6 +55,7 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
bind:close="onClickOverlay"
|
bind:close="onClickOverlay"
|
||||||
>
|
>
|
||||||
<van-overlay
|
<van-overlay
|
||||||
|
rootPortal="{{false}}"
|
||||||
bind:click="onClickOverlay"
|
bind:click="onClickOverlay"
|
||||||
>
|
>
|
||||||
<van-transition
|
<van-transition
|
||||||
@ -120,6 +121,7 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
bind:close="onClickOverlay"
|
bind:close="onClickOverlay"
|
||||||
>
|
>
|
||||||
<van-overlay
|
<van-overlay
|
||||||
|
rootPortal="{{false}}"
|
||||||
bind:click="onClickOverlay"
|
bind:click="onClickOverlay"
|
||||||
>
|
>
|
||||||
<van-transition
|
<van-transition
|
||||||
@ -185,6 +187,7 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
bind:close="onClickOverlay"
|
bind:close="onClickOverlay"
|
||||||
>
|
>
|
||||||
<van-overlay
|
<van-overlay
|
||||||
|
rootPortal="{{false}}"
|
||||||
bind:click="onClickOverlay"
|
bind:click="onClickOverlay"
|
||||||
>
|
>
|
||||||
<van-transition
|
<van-transition
|
||||||
@ -250,6 +253,7 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
bind:close="onClickOverlay"
|
bind:close="onClickOverlay"
|
||||||
>
|
>
|
||||||
<van-overlay
|
<van-overlay
|
||||||
|
rootPortal="{{false}}"
|
||||||
bind:click="onClickOverlay"
|
bind:click="onClickOverlay"
|
||||||
>
|
>
|
||||||
<van-transition
|
<van-transition
|
||||||
@ -315,6 +319,7 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
bind:close="onClickOverlay"
|
bind:close="onClickOverlay"
|
||||||
>
|
>
|
||||||
<van-overlay
|
<van-overlay
|
||||||
|
rootPortal="{{false}}"
|
||||||
bind:click="onClickOverlay"
|
bind:click="onClickOverlay"
|
||||||
>
|
>
|
||||||
<van-transition
|
<van-transition
|
||||||
@ -381,6 +386,7 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
bind:close="onClickOverlay"
|
bind:close="onClickOverlay"
|
||||||
>
|
>
|
||||||
<van-overlay
|
<van-overlay
|
||||||
|
rootPortal="{{false}}"
|
||||||
bind:click="onClickOverlay"
|
bind:click="onClickOverlay"
|
||||||
>
|
>
|
||||||
<van-transition
|
<van-transition
|
||||||
|
@ -1709,6 +1709,7 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
bind:enter="onOpen"
|
bind:enter="onOpen"
|
||||||
>
|
>
|
||||||
<van-overlay
|
<van-overlay
|
||||||
|
rootPortal="{{false}}"
|
||||||
bind:click="onClickOverlay"
|
bind:click="onClickOverlay"
|
||||||
>
|
>
|
||||||
<van-transition
|
<van-transition
|
||||||
|
@ -100,6 +100,7 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
</van-field>
|
</van-field>
|
||||||
<van-popup>
|
<van-popup>
|
||||||
<van-overlay
|
<van-overlay
|
||||||
|
rootPortal="{{false}}"
|
||||||
bind:click="onClickOverlay"
|
bind:click="onClickOverlay"
|
||||||
>
|
>
|
||||||
<van-transition
|
<van-transition
|
||||||
@ -209,6 +210,7 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
</van-field>
|
</van-field>
|
||||||
<van-popup>
|
<van-popup>
|
||||||
<van-overlay
|
<van-overlay
|
||||||
|
rootPortal="{{false}}"
|
||||||
bind:click="onClickOverlay"
|
bind:click="onClickOverlay"
|
||||||
>
|
>
|
||||||
<van-transition
|
<van-transition
|
||||||
@ -318,6 +320,7 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
</van-field>
|
</van-field>
|
||||||
<van-popup>
|
<van-popup>
|
||||||
<van-overlay
|
<van-overlay
|
||||||
|
rootPortal="{{false}}"
|
||||||
bind:click="onClickOverlay"
|
bind:click="onClickOverlay"
|
||||||
>
|
>
|
||||||
<van-transition
|
<van-transition
|
||||||
@ -427,6 +430,7 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
</van-field>
|
</van-field>
|
||||||
<van-popup>
|
<van-popup>
|
||||||
<van-overlay
|
<van-overlay
|
||||||
|
rootPortal="{{false}}"
|
||||||
bind:click="onClickOverlay"
|
bind:click="onClickOverlay"
|
||||||
>
|
>
|
||||||
<van-transition
|
<van-transition
|
||||||
|
@ -268,6 +268,7 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
bind:close="onClickOverlay"
|
bind:close="onClickOverlay"
|
||||||
>
|
>
|
||||||
<van-overlay
|
<van-overlay
|
||||||
|
rootPortal="{{false}}"
|
||||||
bind:click="onClickOverlay"
|
bind:click="onClickOverlay"
|
||||||
>
|
>
|
||||||
<van-transition
|
<van-transition
|
||||||
@ -284,6 +285,7 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
bind:close="onClickOverlay"
|
bind:close="onClickOverlay"
|
||||||
>
|
>
|
||||||
<van-overlay
|
<van-overlay
|
||||||
|
rootPortal="{{false}}"
|
||||||
bind:click="onClickOverlay"
|
bind:click="onClickOverlay"
|
||||||
>
|
>
|
||||||
<van-transition
|
<van-transition
|
||||||
|
@ -141,6 +141,7 @@ Page({
|
|||||||
| safe-area-inset-top | 是否留出顶部安全距离(状态栏高度) | _boolean_ | `false` |
|
| safe-area-inset-top | 是否留出顶部安全距离(状态栏高度) | _boolean_ | `false` |
|
||||||
| safe-area-tab-bar | 是否留出底部 tabbar 安全距离(在使用 tabbar 组件 & 小程序自定义 tabbar 时,popup 组件层级无法盖住 tabbar) | _boolean_ | `false` |
|
| safe-area-tab-bar | 是否留出底部 tabbar 安全距离(在使用 tabbar 组件 & 小程序自定义 tabbar 时,popup 组件层级无法盖住 tabbar) | _boolean_ | `false` |
|
||||||
| lock-scroll `v1.7.3` | 是否锁定背景滚动 | _boolean_ | `true` |
|
| lock-scroll `v1.7.3` | 是否锁定背景滚动 | _boolean_ | `true` |
|
||||||
|
| root-portal `v1.10.14` | 是否从页面中脱离出来,用于解决各种 fixed 失效问题,微信基础库 >= `2.25.2 ` | _boolean_ | `false` |
|
||||||
|
|
||||||
### Events
|
### Events
|
||||||
|
|
||||||
|
@ -64,6 +64,10 @@ VantComponent({
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
value: true,
|
value: true,
|
||||||
},
|
},
|
||||||
|
rootPortal: {
|
||||||
|
type: Boolean,
|
||||||
|
value: false,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
<wxs src="../wxs/utils.wxs" module="utils" />
|
<wxs src="../wxs/utils.wxs" module="utils" />
|
||||||
<wxs src="./index.wxs" module="computed" />
|
<wxs src="./index.wxs" module="computed" />
|
||||||
|
|
||||||
|
<import src="./popup.wxml" />
|
||||||
|
|
||||||
<van-overlay
|
<van-overlay
|
||||||
wx:if="{{ overlay }}"
|
wx:if="{{ overlay }}"
|
||||||
show="{{ show }}"
|
show="{{ show }}"
|
||||||
@ -9,18 +11,11 @@
|
|||||||
duration="{{ duration }}"
|
duration="{{ duration }}"
|
||||||
bind:click="onClickOverlay"
|
bind:click="onClickOverlay"
|
||||||
lock-scroll="{{ lockScroll }}"
|
lock-scroll="{{ lockScroll }}"
|
||||||
|
root-portal="{{ rootPortal }}"
|
||||||
/>
|
/>
|
||||||
<view
|
|
||||||
wx:if="{{ inited }}"
|
<root-portal wx:if="{{ rootPortal }}">
|
||||||
class="custom-class {{ classes }} {{ utils.bem('popup', [position, { round, safe: safeAreaInsetBottom, safeTop: safeAreaInsetTop, safeTabBar: safeAreaTabBar }]) }}"
|
<include src="./popup.wxml" />
|
||||||
style="{{ computed.popupStyle({ zIndex, currentDuration, display, customStyle }) }}"
|
</root-portal>
|
||||||
bind:transitionend="onTransitionEnd"
|
|
||||||
>
|
<include wx:else src="./popup.wxml" />
|
||||||
<slot />
|
|
||||||
<van-icon
|
|
||||||
wx:if="{{ closeable }}"
|
|
||||||
name="{{ closeIcon }}"
|
|
||||||
class="close-icon-class van-popup__close-icon van-popup__close-icon--{{ closeIconPosition }}"
|
|
||||||
bind:tap="onClickCloseIcon"
|
|
||||||
/>
|
|
||||||
</view>
|
|
||||||
|
14
packages/popup/popup.wxml
Normal file
14
packages/popup/popup.wxml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<view
|
||||||
|
wx:if="{{ inited }}"
|
||||||
|
class="custom-class {{ classes }} {{ utils.bem('popup', [position, { round, safe: safeAreaInsetBottom, safeTop: safeAreaInsetTop, safeTabBar: safeAreaTabBar }]) }}"
|
||||||
|
style="{{ computed.popupStyle({ zIndex, currentDuration, display, customStyle }) }}"
|
||||||
|
bind:transitionend="onTransitionEnd"
|
||||||
|
>
|
||||||
|
<slot />
|
||||||
|
<van-icon
|
||||||
|
wx:if="{{ closeable }}"
|
||||||
|
name="{{ closeIcon }}"
|
||||||
|
class="close-icon-class van-popup__close-icon van-popup__close-icon--{{ closeIconPosition }}"
|
||||||
|
bind:tap="onClickCloseIcon"
|
||||||
|
/>
|
||||||
|
</view>
|
@ -46,6 +46,7 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
bind:close="hideBasic"
|
bind:close="hideBasic"
|
||||||
>
|
>
|
||||||
<van-overlay
|
<van-overlay
|
||||||
|
rootPortal="{{false}}"
|
||||||
bind:click="onClickOverlay"
|
bind:click="onClickOverlay"
|
||||||
>
|
>
|
||||||
<van-transition
|
<van-transition
|
||||||
@ -194,6 +195,7 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
bind:close="hideTop"
|
bind:close="hideTop"
|
||||||
>
|
>
|
||||||
<van-overlay
|
<van-overlay
|
||||||
|
rootPortal="{{false}}"
|
||||||
bind:click="onClickOverlay"
|
bind:click="onClickOverlay"
|
||||||
>
|
>
|
||||||
<van-transition
|
<van-transition
|
||||||
@ -207,6 +209,7 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
bind:close="hideBottom"
|
bind:close="hideBottom"
|
||||||
>
|
>
|
||||||
<van-overlay
|
<van-overlay
|
||||||
|
rootPortal="{{false}}"
|
||||||
bind:click="onClickOverlay"
|
bind:click="onClickOverlay"
|
||||||
>
|
>
|
||||||
<van-transition
|
<van-transition
|
||||||
@ -220,6 +223,7 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
bind:close="hideLeft"
|
bind:close="hideLeft"
|
||||||
>
|
>
|
||||||
<van-overlay
|
<van-overlay
|
||||||
|
rootPortal="{{false}}"
|
||||||
bind:click="onClickOverlay"
|
bind:click="onClickOverlay"
|
||||||
>
|
>
|
||||||
<van-transition
|
<van-transition
|
||||||
@ -233,6 +237,7 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
bind:close="hideRight"
|
bind:close="hideRight"
|
||||||
>
|
>
|
||||||
<van-overlay
|
<van-overlay
|
||||||
|
rootPortal="{{false}}"
|
||||||
bind:click="onClickOverlay"
|
bind:click="onClickOverlay"
|
||||||
>
|
>
|
||||||
<van-transition
|
<van-transition
|
||||||
@ -350,6 +355,7 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
bind:close="hideCloseIcon"
|
bind:close="hideCloseIcon"
|
||||||
>
|
>
|
||||||
<van-overlay
|
<van-overlay
|
||||||
|
rootPortal="{{false}}"
|
||||||
bind:click="onClickOverlay"
|
bind:click="onClickOverlay"
|
||||||
>
|
>
|
||||||
<van-transition
|
<van-transition
|
||||||
@ -363,6 +369,7 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
bind:close="hideCustomCloseIcon"
|
bind:close="hideCustomCloseIcon"
|
||||||
>
|
>
|
||||||
<van-overlay
|
<van-overlay
|
||||||
|
rootPortal="{{false}}"
|
||||||
bind:click="onClickOverlay"
|
bind:click="onClickOverlay"
|
||||||
>
|
>
|
||||||
<van-transition
|
<van-transition
|
||||||
@ -376,6 +383,7 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
bind:close="hideCustomIconPosition"
|
bind:close="hideCustomIconPosition"
|
||||||
>
|
>
|
||||||
<van-overlay
|
<van-overlay
|
||||||
|
rootPortal="{{false}}"
|
||||||
bind:click="onClickOverlay"
|
bind:click="onClickOverlay"
|
||||||
>
|
>
|
||||||
<van-transition
|
<van-transition
|
||||||
@ -431,6 +439,7 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
bind:close="hideRound"
|
bind:close="hideRound"
|
||||||
>
|
>
|
||||||
<van-overlay
|
<van-overlay
|
||||||
|
rootPortal="{{false}}"
|
||||||
bind:click="onClickOverlay"
|
bind:click="onClickOverlay"
|
||||||
>
|
>
|
||||||
<van-transition
|
<van-transition
|
||||||
|
@ -56,6 +56,7 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
bind:close="onClose"
|
bind:close="onClose"
|
||||||
>
|
>
|
||||||
<van-overlay
|
<van-overlay
|
||||||
|
rootPortal="{{false}}"
|
||||||
bind:click="onClickOverlay"
|
bind:click="onClickOverlay"
|
||||||
>
|
>
|
||||||
<van-transition
|
<van-transition
|
||||||
@ -123,6 +124,7 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
bind:close="onClose"
|
bind:close="onClose"
|
||||||
>
|
>
|
||||||
<van-overlay
|
<van-overlay
|
||||||
|
rootPortal="{{false}}"
|
||||||
bind:click="onClickOverlay"
|
bind:click="onClickOverlay"
|
||||||
>
|
>
|
||||||
<van-transition
|
<van-transition
|
||||||
@ -190,6 +192,7 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
bind:close="onClose"
|
bind:close="onClose"
|
||||||
>
|
>
|
||||||
<van-overlay
|
<van-overlay
|
||||||
|
rootPortal="{{false}}"
|
||||||
bind:click="onClickOverlay"
|
bind:click="onClickOverlay"
|
||||||
>
|
>
|
||||||
<van-transition
|
<van-transition
|
||||||
@ -257,6 +260,7 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
bind:close="onClose"
|
bind:close="onClose"
|
||||||
>
|
>
|
||||||
<van-overlay
|
<van-overlay
|
||||||
|
rootPortal="{{false}}"
|
||||||
bind:click="onClickOverlay"
|
bind:click="onClickOverlay"
|
||||||
>
|
>
|
||||||
<van-transition
|
<van-transition
|
||||||
|
@ -248,6 +248,7 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
bind:close="onClickOverlay"
|
bind:close="onClickOverlay"
|
||||||
>
|
>
|
||||||
<van-overlay
|
<van-overlay
|
||||||
|
rootPortal="{{false}}"
|
||||||
bind:click="onClickOverlay"
|
bind:click="onClickOverlay"
|
||||||
>
|
>
|
||||||
<van-transition
|
<van-transition
|
||||||
|
@ -169,6 +169,7 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
bind:close="onClickOverlay"
|
bind:close="onClickOverlay"
|
||||||
>
|
>
|
||||||
<van-overlay
|
<van-overlay
|
||||||
|
rootPortal="{{false}}"
|
||||||
bind:click="onClickOverlay"
|
bind:click="onClickOverlay"
|
||||||
>
|
>
|
||||||
<van-transition
|
<van-transition
|
||||||
|
Loading…
x
Reference in New Issue
Block a user