fix(FloatingPanel): remove passive event warning (#11992)

This commit is contained in:
neverland 2023-06-17 21:25:50 +08:00 committed by GitHub
parent 4672910b58
commit 235cfa1b56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 5 deletions

View File

@ -16,7 +16,7 @@ import {
} from '../utils'; } from '../utils';
// Composables // Composables
import { useWindowSize } from '@vant/use'; import { useWindowSize, useEventListener } from '@vant/use';
import { useLockScroll } from '../composables/use-lock-scroll'; import { useLockScroll } from '../composables/use-lock-scroll';
import { useTouch } from '../composables/use-touch'; import { useTouch } from '../composables/use-touch';
import { useSyncPropRef } from '../composables/use-sync-prop-ref'; import { useSyncPropRef } from '../composables/use-sync-prop-ref';
@ -142,13 +142,15 @@ export default defineComponent({
useLockScroll(rootRef, () => true); useLockScroll(rootRef, () => true);
// useEventListener will set passive to `false` to eliminate the warning of Chrome
useEventListener('touchmove', onTouchmove, { target: rootRef });
return () => ( return () => (
<div <div
class={[bem(), { 'van-safe-area-bottom': props.safeAreaInsetBottom }]} class={[bem(), { 'van-safe-area-bottom': props.safeAreaInsetBottom }]}
ref={rootRef} ref={rootRef}
style={rootStyle.value} style={rootStyle.value}
onTouchstartPassive={onTouchstart} onTouchstartPassive={onTouchstart}
onTouchmove={onTouchmove}
onTouchend={onTouchend} onTouchend={onTouchend}
onTouchcancel={onTouchend} onTouchcancel={onTouchend}
> >

View File

@ -44,7 +44,7 @@ For example, you can make the panel stop at three positions: `100px`, 40% of the
```html ```html
<van-floating-panel v-model:height="height" :anchors="anchors"> <van-floating-panel v-model:height="height" :anchors="anchors">
<div style="text-align: center; padding: 15px"> <div style="text-align: center; padding: 15px">
<p>Panel Show Height {{ height }} px</p> <p>Panel Show Height {{ height.toFixed(0) }} px</p>
</div> </div>
</van-floating-panel> </van-floating-panel>
``` ```

View File

@ -44,7 +44,7 @@ FloatingPanel 的默认高度为 `100px`,用户可以拖动来展开面板,
```html ```html
<van-floating-panel v-model:height="height" :anchors="anchors"> <van-floating-panel v-model:height="height" :anchors="anchors">
<div style="text-align: center; padding: 15px"> <div style="text-align: center; padding: 15px">
<p>面板显示高度 {{ height }} px</p> <p>面板显示高度 {{ height.toFixed(0) }} px</p>
</div> </div>
</van-floating-panel> </van-floating-panel>
``` ```

View File

@ -52,7 +52,7 @@ const height = ref(anchors[0]);
<van-tab :title="t('customAnchors')"> <van-tab :title="t('customAnchors')">
<van-floating-panel v-model:height="height" :anchors="anchors"> <van-floating-panel v-model:height="height" :anchors="anchors">
<div style="text-align: center; padding: 15px"> <div style="text-align: center; padding: 15px">
<p>{{ t('panelShowHeight') }} {{ height }} px</p> <p>{{ t('panelShowHeight') }} {{ height.toFixed(0) }} px</p>
</div> </div>
</van-floating-panel> </van-floating-panel>
</van-tab> </van-tab>