Skip to content

Commit

Permalink
fix(VNavigationDrawer): account for VOverlay body offset when sticky
Browse files Browse the repository at this point in the history
  • Loading branch information
KaelWD committed May 2, 2023
1 parent 025a054 commit c45cc65
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/vuetify/src/components/VNavigationDrawer/sticky.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export function useSticky ({ rootEl, isSticky, layoutItemStyles }: StickyProps)
Math.max(stuckPosition.value, layoutTop) -
window.scrollY -
window.innerHeight
const bodyScroll = parseFloat(getComputedStyle(rootEl.value!).getPropertyValue('--v-body-scroll-y')) || 0

if (rect.height < window.innerHeight - layoutTop) {
isStuck.value = 'top'
Expand All @@ -55,14 +56,19 @@ export function useSticky ({ rootEl, isSticky, layoutItemStyles }: StickyProps)
(direction === 'up' && isStuck.value === 'bottom') ||
(direction === 'down' && isStuck.value === 'top')
) {
stuckPosition.value = window.scrollY + rect.top
stuckPosition.value = window.scrollY + rect.top - bodyScroll
isStuck.value = true
} else if (direction === 'down' && bottom <= 0) {
stuckPosition.value = 0
isStuck.value = 'bottom'
} else if (direction === 'up' && top <= 0) {
stuckPosition.value = rect.top + top
isStuck.value = 'top'
if (!bodyScroll) {
stuckPosition.value = rect.top + top
isStuck.value = 'top'
} else if (isStuck.value !== 'top') {
stuckPosition.value = -top + bodyScroll + layoutTop
isStuck.value = 'top'
}
}

lastScrollTop = window.scrollY
Expand Down

0 comments on commit c45cc65

Please sign in to comment.