virtual scrolling improvements
This commit is contained in:
parent
1c1526c065
commit
58bc4b3347
3 changed files with 23 additions and 11 deletions
|
|
@ -93,6 +93,7 @@ const conversation = {
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
emits: ['update:virtualHeight'],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
focused: null,
|
focused: null,
|
||||||
|
|
@ -101,6 +102,7 @@ const conversation = {
|
||||||
inlineDivePosition: null,
|
inlineDivePosition: null,
|
||||||
loadStatusError: null,
|
loadStatusError: null,
|
||||||
unsuspendibleIds: new Set(),
|
unsuspendibleIds: new Set(),
|
||||||
|
virtualHeight: 120,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
|
@ -108,6 +110,9 @@ const conversation = {
|
||||||
this.fetchConversation()
|
this.fetchConversation()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
mounted() {
|
||||||
|
this.updateVirtualHeight()
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
status() {
|
status() {
|
||||||
return useStatusesStore().allStatuses.get(this.statusId)
|
return useStatusesStore().allStatuses.get(this.statusId)
|
||||||
|
|
@ -360,8 +365,8 @@ const conversation = {
|
||||||
return !!(this.expanded || this.isPage)
|
return !!(this.expanded || this.isPage)
|
||||||
},
|
},
|
||||||
hiddenStyle() {
|
hiddenStyle() {
|
||||||
const height = this.status?.virtualHeight || '120px'
|
if (this.expanded) return {}
|
||||||
return this.virtualHidden ? { height } : {}
|
return { height: this.virtualHeight + 'px' }
|
||||||
},
|
},
|
||||||
threadDisplayStatus() {
|
threadDisplayStatus() {
|
||||||
return this.conversation.reduce((a, k) => {
|
return this.conversation.reduce((a, k) => {
|
||||||
|
|
@ -426,11 +431,14 @@ const conversation = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
virtualHidden() {
|
virtualHidden() {
|
||||||
useStatusesStore().setVirtualHeight({
|
this.updateVirtualHeight()
|
||||||
statusId: this.statusId,
|
|
||||||
height: `${this.$el.clientHeight}px`,
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
|
status: {
|
||||||
|
handler() {
|
||||||
|
this.updateVirtualHeight()
|
||||||
|
},
|
||||||
|
deep: true,
|
||||||
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
fetchConversation() {
|
fetchConversation() {
|
||||||
|
|
@ -607,6 +615,9 @@ const conversation = {
|
||||||
this.threadDisplayStatusObject = {}
|
this.threadDisplayStatusObject = {}
|
||||||
},
|
},
|
||||||
onStatusSuspendStateChange({ id, suspend }) {
|
onStatusSuspendStateChange({ id, suspend }) {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.virtualHeight = this.$refs.body.clientHeight
|
||||||
|
})
|
||||||
if (!suspend) {
|
if (!suspend) {
|
||||||
this.unsuspendibleIds.add(id)
|
this.unsuspendibleIds.add(id)
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -618,6 +629,10 @@ const conversation = {
|
||||||
this.$router.push({ name: 'conversation', params: { id: data.id } })
|
this.$router.push({ name: 'conversation', params: { id: data.id } })
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
updateVirtualHeight() {
|
||||||
|
this.$emit('update:virtualHeight', { id: this.status.id, height: this.virtualHeight })
|
||||||
|
this.virtualHeight = this.$refs.body.clientHeight
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@
|
||||||
<div
|
<div
|
||||||
v-if="isPage && !status"
|
v-if="isPage && !status"
|
||||||
class="conversation-body"
|
class="conversation-body"
|
||||||
|
ref="body"
|
||||||
:class="{ 'panel-body': isExpanded }"
|
:class="{ 'panel-body': isExpanded }"
|
||||||
>
|
>
|
||||||
<p v-if="!loadStatusError">
|
<p v-if="!loadStatusError">
|
||||||
|
|
@ -56,6 +57,7 @@
|
||||||
<div
|
<div
|
||||||
v-else
|
v-else
|
||||||
class="conversation-body"
|
class="conversation-body"
|
||||||
|
ref="body"
|
||||||
:class="{ 'panel-body': isExpanded }"
|
:class="{ 'panel-body': isExpanded }"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
|
|
||||||
|
|
@ -540,10 +540,5 @@ export const useStatusesStore = defineStore('statuses', {
|
||||||
})
|
})
|
||||||
return removed
|
return removed
|
||||||
},
|
},
|
||||||
|
|
||||||
// Misc
|
|
||||||
setVirtualHeight({ statusId, height }) {
|
|
||||||
this.allStatuses.get(statusId).virtualHeight = height
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue