Skip to content

Commit

Permalink
fix(timeline): autoscroll when selecting layer
Browse files Browse the repository at this point in the history
  • Loading branch information
Akryum committed May 12, 2021
1 parent 370abfd commit 3a783f8
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions packages/app-frontend/src/features/timeline/TimelineEventList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ export default defineComponent({
if (value) {
onScroll()
}
})
}, { immediate: true })
watch(tabId, () => {
scrollToInspectedEvent()
})
}, { immediate: true })
function scrollToInspectedEvent () {
if (!scroller.value) return
Expand All @@ -135,20 +135,22 @@ export default defineComponent({
watch(inspectedEvent, () => {
checkScrollToInspectedEvent()
})
}, { immediate: true })
function checkScrollToInspectedEvent () {
if (!scroller.value) return
requestAnimationFrame(() => {
if (!scroller.value) return
const scrollerEl = scroller.value.$el
const scrollerEl = scroller.value.$el
const index = filteredEvents.value.indexOf(inspectedEvent.value)
const minPosition = itemHeight * index
const maxPosition = minPosition + itemHeight
const index = filteredEvents.value.indexOf(inspectedEvent.value)
const minPosition = itemHeight * index
const maxPosition = minPosition + itemHeight
if (scrollerEl.scrollTop > minPosition || scrollerEl.scrollTop + scrollerEl.clientHeight < maxPosition) {
scrollToInspectedEvent()
}
if (scrollerEl.scrollTop > minPosition || scrollerEl.scrollTop + scrollerEl.clientHeight < maxPosition) {
scrollToInspectedEvent()
}
})
}
// Auto bottom scroll
Expand All @@ -165,7 +167,7 @@ export default defineComponent({
if (isAtScrollBottom.value) {
scrollToBottom()
}
})
}, { immediate: true })
// List interactions
Expand Down

0 comments on commit 3a783f8

Please sign in to comment.