From 4f9555c64af2a475b8e052f98ab3ecddba1d8418 Mon Sep 17 00:00:00 2001 From: tanjinzhou <415800467@qq.com> Date: Fri, 18 Dec 2020 18:54:18 +0800 Subject: [PATCH] fix: passive warning #3392 --- components/vc-trigger/Trigger.jsx | 2 +- components/vc-util/Dom/addEventListener.js | 2 +- components/vc-virtual-list/List.tsx | 4 ++-- components/vc-virtual-list/ScrollBar.tsx | 12 ++++++------ .../vc-virtual-list/hooks/useMobileTouchMove.ts | 8 ++++---- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/components/vc-trigger/Trigger.jsx b/components/vc-trigger/Trigger.jsx index 63b49daa1..d97f417aa 100644 --- a/components/vc-trigger/Trigger.jsx +++ b/components/vc-trigger/Trigger.jsx @@ -166,7 +166,7 @@ export default defineComponent({ currentDocument, 'touchstart', this.onDocumentClick, - supportsPassive ? { passive: true } : false, + supportsPassive ? { passive: false } : false, ); } // close popup when trigger type contains 'onContextmenu' and document is scrolling. diff --git a/components/vc-util/Dom/addEventListener.js b/components/vc-util/Dom/addEventListener.js index 71c7c39be..d307e7cbe 100644 --- a/components/vc-util/Dom/addEventListener.js +++ b/components/vc-util/Dom/addEventListener.js @@ -8,7 +8,7 @@ export default function addEventListenerWrap(target, eventType, cb, option) { supportsPassive && (eventType === 'touchstart' || eventType === 'touchmove' || eventType === 'wheel') ) { - opt = { passive: true }; + opt = { passive: false }; } target.addEventListener(eventType, cb, opt); } diff --git a/components/vc-virtual-list/List.tsx b/components/vc-virtual-list/List.tsx index c62a91ea6..9e0a6e03a 100644 --- a/components/vc-virtual-list/List.tsx +++ b/components/vc-virtual-list/List.tsx @@ -268,7 +268,7 @@ const List = defineComponent({ componentRef.value.removeEventListener( 'wheel', onRawWheel, - supportsPassive ? ({ passive: true } as EventListenerOptions) : false, + supportsPassive ? ({ passive: false } as EventListenerOptions) : false, ); componentRef.value.removeEventListener('DOMMouseScroll', onFireFoxScroll as any); componentRef.value.removeEventListener('MozMousePixelScroll', onMozMousePixelScroll as any); @@ -281,7 +281,7 @@ const List = defineComponent({ componentRef.value.addEventListener( 'wheel', onRawWheel, - supportsPassive ? ({ passive: true } as EventListenerOptions) : false, + supportsPassive ? ({ passive: false } as EventListenerOptions) : false, ); componentRef.value.addEventListener('DOMMouseScroll', onFireFoxScroll as any); componentRef.value.addEventListener('MozMousePixelScroll', onMozMousePixelScroll as any); diff --git a/components/vc-virtual-list/ScrollBar.tsx b/components/vc-virtual-list/ScrollBar.tsx index 3e8ce9160..6568ab6cf 100644 --- a/components/vc-virtual-list/ScrollBar.tsx +++ b/components/vc-virtual-list/ScrollBar.tsx @@ -64,12 +64,12 @@ export default defineComponent({ this.scrollbarRef.current.addEventListener( 'touchstart', this.onScrollbarTouchStart, - supportsPassive ? ({ passive: true } as EventListenerOptions) : false, + supportsPassive ? ({ passive: false } as EventListenerOptions) : false, ); this.thumbRef.current.addEventListener( 'touchstart', this.onMouseDown, - supportsPassive ? ({ passive: true } as EventListenerOptions) : false, + supportsPassive ? ({ passive: false } as EventListenerOptions) : false, ); }, @@ -104,7 +104,7 @@ export default defineComponent({ this.thumbRef.current.addEventListener( 'touchmove', this.onMouseMove, - supportsPassive ? ({ passive: true } as EventListenerOptions) : false, + supportsPassive ? ({ passive: false } as EventListenerOptions) : false, ); this.thumbRef.current.addEventListener('touchend', this.onMouseUp); }, @@ -116,17 +116,17 @@ export default defineComponent({ this.scrollbarRef.current.removeEventListener( 'touchstart', this.onScrollbarTouchStart, - supportsPassive ? ({ passive: true } as EventListenerOptions) : false, + supportsPassive ? ({ passive: false } as EventListenerOptions) : false, ); this.thumbRef.current.removeEventListener( 'touchstart', this.onMouseDown, - supportsPassive ? ({ passive: true } as EventListenerOptions) : false, + supportsPassive ? ({ passive: false } as EventListenerOptions) : false, ); this.thumbRef.current.removeEventListener( 'touchmove', this.onMouseMove, - supportsPassive ? ({ passive: true } as EventListenerOptions) : false, + supportsPassive ? ({ passive: false } as EventListenerOptions) : false, ); this.thumbRef.current.removeEventListener('touchend', this.onMouseUp); diff --git a/components/vc-virtual-list/hooks/useMobileTouchMove.ts b/components/vc-virtual-list/hooks/useMobileTouchMove.ts index 45ad54435..f6c6a9374 100644 --- a/components/vc-virtual-list/hooks/useMobileTouchMove.ts +++ b/components/vc-virtual-list/hooks/useMobileTouchMove.ts @@ -23,7 +23,7 @@ export default function useMobileTouchMove( onTouchMove, supportsPassive ? ({ - passive: true, + passive: false, } as EventListenerOptions) : false, ); @@ -72,7 +72,7 @@ export default function useMobileTouchMove( onTouchMove, supportsPassive ? ({ - passive: true, + passive: false, } as EventListenerOptions) : false, ); @@ -86,7 +86,7 @@ export default function useMobileTouchMove( onTouchStart, supportsPassive ? ({ - passive: true, + passive: false, } as EventListenerOptions) : false, ); @@ -98,7 +98,7 @@ export default function useMobileTouchMove( onTouchStart, supportsPassive ? ({ - passive: true, + passive: false, } as EventListenerOptions) : false, );