scrolling
This commit is contained in:
parent
98b30733ad
commit
749d42978f
3 changed files with 24 additions and 4 deletions
|
|
@ -153,6 +153,11 @@ const ChatMessage = {
|
||||||
menuOpened: false,
|
menuOpened: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
focused: function (value) {
|
||||||
|
this.scrollIfFocused(value)
|
||||||
|
},
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onHover(bool) {
|
onHover(bool) {
|
||||||
this.$emit('hover', {
|
this.$emit('hover', {
|
||||||
|
|
@ -188,6 +193,22 @@ const ChatMessage = {
|
||||||
this.hovered = false
|
this.hovered = false
|
||||||
this.menuOpened = false
|
this.menuOpened = false
|
||||||
},
|
},
|
||||||
|
scrollIfFocused(focused) {
|
||||||
|
if (this.$el.getBoundingClientRect == null) return
|
||||||
|
if (focused) {
|
||||||
|
const rect = this.$el.getBoundingClientRect()
|
||||||
|
if (rect.top < 100) {
|
||||||
|
// Post is above screen, match its top to screen top
|
||||||
|
window.scrollBy(0, rect.top - 100)
|
||||||
|
} else if (rect.height >= window.innerHeight - 50) {
|
||||||
|
// Post we want to see is taller than screen so match its top to screen top
|
||||||
|
window.scrollBy(0, rect.top - 100)
|
||||||
|
} else if (rect.bottom > window.innerHeight - 50) {
|
||||||
|
// Post is below screen, match its bottom to screen bottom
|
||||||
|
window.scrollBy(0, rect.bottom - window.innerHeight + 50)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
>
|
>
|
||||||
<h1 class="title">
|
<h1 class="title">
|
||||||
<RichContent
|
<RichContent
|
||||||
v-if="conversation[0].summary"
|
v-if="conversation[0]?.summary"
|
||||||
:html="conversation[0].summary"
|
:html="conversation[0].summary"
|
||||||
/>
|
/>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
|
|
|
||||||
|
|
@ -540,10 +540,9 @@ const Status = {
|
||||||
toggleThreadDisplay() {
|
toggleThreadDisplay() {
|
||||||
this.controlledToggleThreadDisplay()
|
this.controlledToggleThreadDisplay()
|
||||||
},
|
},
|
||||||
scrollIfFocused(focusedId) {
|
scrollIfFocused(focused) {
|
||||||
if (this.$el.getBoundingClientRect == null) return
|
if (this.$el.getBoundingClientRect == null) return
|
||||||
const id = focusedId
|
if (focused) {
|
||||||
if (this.status.id === id) {
|
|
||||||
const rect = this.$el.getBoundingClientRect()
|
const rect = this.$el.getBoundingClientRect()
|
||||||
if (rect.top < 100) {
|
if (rect.top < 100) {
|
||||||
// Post is above screen, match its top to screen top
|
// Post is above screen, match its top to screen top
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue