perf: add correct passive flag to improve scroll performance (#10951)

This commit is contained in:
neverland 2022-08-21 17:33:57 +08:00 committed by GitHub
parent ca583e1075
commit cb93bd2da3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 5 deletions

View File

@ -145,7 +145,10 @@ export default defineComponent({
linkChildren({ id, props, offset });
useClickAway(root, onClickAway);
useEventListener('scroll', onScroll, { target: scrollParent });
useEventListener('scroll', onScroll, {
target: scrollParent,
passive: true,
});
return () => (
<div ref={root} class={bem()}>

View File

@ -182,7 +182,10 @@ export default defineComponent({
nextTick(onScroll);
};
useEventListener('scroll', onScroll, { target: scrollParent });
useEventListener('scroll', onScroll, {
target: scrollParent,
passive: true,
});
onMounted(init);

View File

@ -166,7 +166,10 @@ export default defineComponent({
useExpose<ListExpose>({ check });
useEventListener('scroll', check, { target: scrollParent });
useEventListener('scroll', check, {
target: scrollParent,
passive: true,
});
return () => {
const Content = slots.default?.();

View File

@ -140,7 +140,10 @@ export default defineComponent({
(value) => emit('change', value)
);
useEventListener('scroll', onScroll, { target: scrollParent });
useEventListener('scroll', onScroll, {
target: scrollParent,
passive: true,
});
useVisibilityChange(root, onScroll);
return () => (

View File

@ -485,7 +485,10 @@ export default defineComponent({
onActivated(setLine);
onPopupReopen(setLine);
onMountedOrActivated(init);
useEventListener('scroll', onScroll, { target: scroller });
useEventListener('scroll', onScroll, {
target: scroller,
passive: true,
});
linkChildren({
id,