From 07c0aad1bdca0e541362285ef1d7f78df37ee25d Mon Sep 17 00:00:00 2001 From: yulj5 Date: Thu, 11 May 2023 16:23:06 +0800 Subject: [PATCH 1/2] fix(useScroll) support window in setArrivedState --- packages/core/useScroll/index.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/core/useScroll/index.ts b/packages/core/useScroll/index.ts index c2c75902b8b..3c26b721309 100644 --- a/packages/core/useScroll/index.ts +++ b/packages/core/useScroll/index.ts @@ -161,6 +161,9 @@ export function useScroll( const onScrollEndDebounced = useDebounceFn(onScrollEnd, throttle + idle) const setArrivedState = (target: HTMLElement | SVGElement | Window | Document | null | undefined) => { + if (target === window) + target = target.document + const el = ( target === document ? (target as Document).documentElement : target ) as HTMLElement From 8f4faf507799d878728457ee9a96650a35d84b1c Mon Sep 17 00:00:00 2001 From: smallnine Date: Sat, 13 May 2023 09:05:46 +0800 Subject: [PATCH 2/2] merge judgement into on line --- packages/core/useScroll/index.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/core/useScroll/index.ts b/packages/core/useScroll/index.ts index 3c26b721309..e064e7342ab 100644 --- a/packages/core/useScroll/index.ts +++ b/packages/core/useScroll/index.ts @@ -161,11 +161,10 @@ export function useScroll( const onScrollEndDebounced = useDebounceFn(onScrollEnd, throttle + idle) const setArrivedState = (target: HTMLElement | SVGElement | Window | Document | null | undefined) => { - if (target === window) - target = target.document - const el = ( - target === document ? (target as Document).documentElement : target + target === window + ? (target as Window).document.documentElement + : target === document ? (target as Document).documentElement : target ) as HTMLElement const { display, flexDirection } = getComputedStyle(el)