diff --git a/src/index-bar/index.js b/src/index-bar/index.js index dfccb48be..893d1ba09 100644 --- a/src/index-bar/index.js +++ b/src/index-bar/index.js @@ -113,7 +113,7 @@ export default createComponent({ }; const onScroll = () => { - if (isHidden(root.value)) { + if (isHidden(root)) { return; } diff --git a/src/list/index.js b/src/list/index.js index d3ba5cf47..cfb38e2e2 100644 --- a/src/list/index.js +++ b/src/list/index.js @@ -67,7 +67,7 @@ export default createComponent({ scrollParentRect.bottom - scrollParentRect.top; /* istanbul ignore next */ - if (!scrollParentHeight || isHidden(root.value)) { + if (!scrollParentHeight || isHidden(root)) { return false; } diff --git a/src/sticky/index.js b/src/sticky/index.js index db3114c0b..7f1425ac5 100644 --- a/src/sticky/index.js +++ b/src/sticky/index.js @@ -61,7 +61,7 @@ export default createComponent({ }; const onScroll = () => { - if (isHidden(root.value)) { + if (isHidden(root)) { return; } diff --git a/src/utils/dom/style.ts b/src/utils/dom/style.ts index e3fe897b1..e5f9b0ac2 100644 --- a/src/utils/dom/style.ts +++ b/src/utils/dom/style.ts @@ -1,4 +1,7 @@ -export function isHidden(el: HTMLElement) { +import { unref, Ref } from 'vue'; + +export function isHidden(elementRef: HTMLElement | Ref) { + const el = unref(elementRef); const style = window.getComputedStyle(el); const hidden = style.display === 'none';