Browse Source

fix: passive warning #3392

pull/3433/head
tanjinzhou 4 years ago
parent
commit
4f9555c64a
  1. 2
      components/vc-trigger/Trigger.jsx
  2. 2
      components/vc-util/Dom/addEventListener.js
  3. 4
      components/vc-virtual-list/List.tsx
  4. 12
      components/vc-virtual-list/ScrollBar.tsx
  5. 8
      components/vc-virtual-list/hooks/useMobileTouchMove.ts

2
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.

2
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);
}

4
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);

12
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);

8
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,
);

Loading…
Cancel
Save