Skip to content

Commit

Permalink
Use a different technique to scroll mobile list to selected location …
Browse files Browse the repository at this point in the history
…when hidden

Using `scrollIntoView` scrolls the item into view not just horizontally in the MobileList, but also vertically in the whole viewport, causing the viewport to jumpt down and then transition up with the list (looking janky).
  • Loading branch information
sisou committed Sep 7, 2023
1 parent 7c23e54 commit 76b477f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/components/elements/MobileList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,21 @@ function handleSelectedUuidUpdate(uuid: string | undefined, smooth = true) {
if (scrollingList)
return
const card = document.querySelector(`[data-card-uuid="${uuid}"]`)
if (!card)
return
scrollingIntoView = true
document.querySelector(`[data-card-uuid="${uuid}"]`)?.scrollIntoView({ behavior: smooth ? 'smooth' : 'instant' })
if (smooth) {
card.scrollIntoView({ behavior: 'smooth' })
}
else {
scrollRoot.value!.scrollTo({
left: card.getBoundingClientRect().left,
behavior: 'instant',
})
}
if (smooth) {
if ('onscrollend' in window) {
Expand Down

0 comments on commit 76b477f

Please sign in to comment.