Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Overlay): add lock-scroll prop #4383

Merged
merged 5 commits into from
Aug 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions packages/overlay/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,14 @@ Page({

### Props

| 参数 | 说明 | 类型 | 默认值 | 版本 |
| ------------ | ---------------- | ------------------ | ------- | ---- |
| show | 是否展示遮罩层 | _boolean_ | `false` | - |
| z-index | z-index 层级 | _string \| number_ | `1` | - |
| duration | 动画时长,单位秒 | _string \| number_ | `0.3` | - |
| class-name | 自定义类名 | _string_ | - | - |
| custom-style | 自定义样式 | _string_ | - | - |
| 参数 | 说明 | 类型 | 默认值 |
| ------------ | ------------------------------------------------ | ------------------ | ------- |
| show | 是否展示遮罩层 | _boolean_ | `false` |
| z-index | z-index 层级 | _string \| number_ | `1` |
| duration | 动画时长,单位秒 | _string \| number_ | `0.3` |
| class-name | 自定义类名 | _string_ | - |
| custom-style | 自定义样式 | _string_ | - |
| lock-scroll `1.7.3` | 是否锁定背景滚动,锁定时蒙层里的内容也将无法滚动 | _boolean_ | true |

### Events

Expand Down
4 changes: 4 additions & 0 deletions packages/overlay/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ VantComponent({
type: Number,
value: 1,
},
lockScroll: {
type: Boolean,
value: true,
},
},

methods: {
Expand Down
11 changes: 11 additions & 0 deletions packages/overlay/index.wxml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<van-transition
wx:if="{{ lockScroll }}"
show="{{ show }}"
custom-class="van-overlay"
custom-style="z-index: {{ zIndex }}; {{ customStyle }}"
Expand All @@ -8,3 +9,13 @@
>
<slot></slot>
</van-transition>
<van-transition
wx:else
show="{{ show }}"
custom-class="van-overlay"
custom-style="z-index: {{ zIndex }}; {{ customStyle }}"
duration="{{ duration }}"
bind:tap="onClick"
>
<slot></slot>
</van-transition>