Skip to content

Commit

Permalink
fix(useScroll): compatibility for mobile (#1663)
Browse files Browse the repository at this point in the history
  • Loading branch information
YunYouJun committed Jun 16, 2022
1 parent bb0ac66 commit 3a6b9d5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/core/useScroll/index.ts
Expand Up @@ -118,7 +118,12 @@ export function useScroll(
= scrollLeft + eventTarget.clientWidth >= eventTarget.scrollWidth - (offset.right || 0)
x.value = scrollLeft

const scrollTop = eventTarget.scrollTop
let scrollTop = eventTarget.scrollTop

// patch for mobile compatible
if (e.target === document && !scrollTop)
scrollTop = document.body.scrollTop

directions.top = scrollTop < y.value
directions.bottom = scrollTop > y.value
arrivedState.top = scrollTop <= 0 + (offset.top || 0)
Expand Down

0 comments on commit 3a6b9d5

Please sign in to comment.