From b543c22c8b68f95957889ebd57d7546191c0a833 Mon Sep 17 00:00:00 2001 From: inottn Date: Sun, 6 Aug 2023 20:56:41 +0800 Subject: [PATCH] feat(FloatingPanel): add lock-scroll prop (#12157) * feat(FloatingPanel): add lockScroll prop * docs: improve description --- packages/vant/src/floating-panel/FloatingPanel.tsx | 3 ++- packages/vant/src/floating-panel/README.md | 1 + packages/vant/src/floating-panel/README.zh-CN.md | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/vant/src/floating-panel/FloatingPanel.tsx b/packages/vant/src/floating-panel/FloatingPanel.tsx index f0918e61b..7430fb2c4 100644 --- a/packages/vant/src/floating-panel/FloatingPanel.tsx +++ b/packages/vant/src/floating-panel/FloatingPanel.tsx @@ -28,6 +28,7 @@ export const floatingPanelProps = { anchors: makeArrayProp(), duration: makeNumericProp(0.2), contentDraggable: truthProp, + lockScroll: truthProp, safeAreaInsetBottom: truthProp, }; @@ -135,7 +136,7 @@ export default defineComponent({ { immediate: true }, ); - useLockScroll(rootRef, () => true); + useLockScroll(rootRef, () => props.lockScroll); // useEventListener will set passive to `false` to eliminate the warning of Chrome useEventListener('touchmove', onTouchmove, { target: rootRef }); diff --git a/packages/vant/src/floating-panel/README.md b/packages/vant/src/floating-panel/README.md index 05fbf6925..fef9cb371 100644 --- a/packages/vant/src/floating-panel/README.md +++ b/packages/vant/src/floating-panel/README.md @@ -88,6 +88,7 @@ By default, both the header and content areas of FloatingPanel can be dragged, b | anchors | Setting custom anchors, unit `px` | _number[]_ | `[100, window.innerWidth * 0.6]` | | duration | Transition duration, unit second | _number \| string_ | `0.3` | | content-draggable | Allow dragging content | _boolean_ | `true` | +| lock-scroll `v4.6.4` | Whether to lock background scroll | _boolean_ | `true` | | safe-area-inset-bottom | Whether to enable bottom safe area adaptation | _boolean_ | `true` | ### Events diff --git a/packages/vant/src/floating-panel/README.zh-CN.md b/packages/vant/src/floating-panel/README.zh-CN.md index f3e56ec32..24afe3a1a 100644 --- a/packages/vant/src/floating-panel/README.zh-CN.md +++ b/packages/vant/src/floating-panel/README.zh-CN.md @@ -88,6 +88,7 @@ export default { | anchors | 设置自定义锚点, 单位 `px` | _number[]_ | `[100, window.innerWidth * 0.6]` | | duration | 动画时长,单位秒,设置为 0 可以禁用动画 | _number \| string_ | `0.3` | | content-draggable | 允许拖拽内容容器 | _boolean_ | `true` | +| lock-scroll `v4.6.4` | 是否锁定背景滚动 | _boolean_ | `true` | | safe-area-inset-bottom | 是否开启[底部安全区适配](#/zh-CN/advanced-usage#di-bu-an-quan-qu-gua-pei) | _boolean_ | `true` | ### Events