Skip to content

Commit

Permalink
feat(useScrollLock): detect parent with overflow auto
Browse files Browse the repository at this point in the history
  • Loading branch information
dpschen committed Feb 1, 2023
1 parent 99922ec commit 5db6276
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/core/useScrollLock/index.ts
Expand Up @@ -6,7 +6,12 @@ import { useEventListener } from '../useEventListener'

function checkOverflowScroll(ele: Element): boolean {
const style = window.getComputedStyle(ele)
if (style.overflowX === 'scroll' || style.overflowY === 'scroll') {
if (
style.overflowX === 'scroll'
|| style.overflowY === 'scroll'
|| (style.overflowX === 'auto' && ele.clientHeight < ele.scrollHeight)
|| (style.overflowY === 'auto' && ele.clientWidth < ele.scrollWidth)
) {
return true
}
else {
Expand Down

0 comments on commit 5db6276

Please sign in to comment.