Merge branch 'fix-chat-scroll' into 'develop'
fix chat scroll acting unwise Closes #1178 See merge request pleroma/pleroma-fe!1587
This commit is contained in:
commit
2867c69629
|
@ -57,6 +57,7 @@ const Chat = {
|
||||||
},
|
},
|
||||||
unmounted () {
|
unmounted () {
|
||||||
window.removeEventListener('scroll', this.handleScroll)
|
window.removeEventListener('scroll', this.handleScroll)
|
||||||
|
window.removeEventListener('resize', this.handleResize)
|
||||||
if (typeof document.hidden !== 'undefined') document.removeEventListener('visibilitychange', this.handleVisibilityChange, false)
|
if (typeof document.hidden !== 'undefined') document.removeEventListener('visibilitychange', this.handleVisibilityChange, false)
|
||||||
this.$store.dispatch('clearCurrentChat')
|
this.$store.dispatch('clearCurrentChat')
|
||||||
},
|
},
|
||||||
|
@ -135,7 +136,7 @@ const Chat = {
|
||||||
},
|
},
|
||||||
// "Sticks" scroll to bottom instead of top, helps with OSK resizing the viewport
|
// "Sticks" scroll to bottom instead of top, helps with OSK resizing the viewport
|
||||||
handleResize (opts = {}) {
|
handleResize (opts = {}) {
|
||||||
const { expand = false, delayed = false } = opts
|
const { delayed = false } = opts
|
||||||
|
|
||||||
if (delayed) {
|
if (delayed) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
@ -146,10 +147,10 @@ const Chat = {
|
||||||
|
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
const { offsetHeight = undefined } = getScrollPosition()
|
const { offsetHeight = undefined } = getScrollPosition()
|
||||||
const diff = this.lastScrollPosition.offsetHeight - offsetHeight
|
const diff = offsetHeight - this.lastScrollPosition.offsetHeight
|
||||||
if (diff !== 0 || (!this.bottomedOut() && expand)) {
|
if (diff !== 0 && !this.bottomedOut()) {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
window.scrollTo({ top: window.scrollY + diff })
|
window.scrollBy({ top: -Math.trunc(diff) })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.lastScrollPosition = getScrollPosition()
|
this.lastScrollPosition = getScrollPosition()
|
||||||
|
@ -187,6 +188,7 @@ const Chat = {
|
||||||
}, 5000)
|
}, 5000)
|
||||||
},
|
},
|
||||||
handleScroll: _.throttle(function () {
|
handleScroll: _.throttle(function () {
|
||||||
|
this.lastScrollPosition = getScrollPosition()
|
||||||
if (!this.currentChat) { return }
|
if (!this.currentChat) { return }
|
||||||
|
|
||||||
if (this.reachedTop()) {
|
if (this.reachedTop()) {
|
||||||
|
|
Loading…
Reference in New Issue