diff options
| author | Henry Jameson <me@hjkos.com> | 2022-05-22 12:18:20 +0300 |
|---|---|---|
| committer | Henry Jameson <me@hjkos.com> | 2022-05-22 12:18:20 +0300 |
| commit | d137d5800a44e598d67d0134ed071167c1c6e98e (patch) | |
| tree | 65805ce46e67cbc93325882edfbaba06685a1fe6 /src/components | |
| parent | 2c876f455af53e25cd7f193aab9c12031956ec07 (diff) | |
stick chat scroll to bottom to help with OSK resizing the viewport
Diffstat (limited to 'src/components')
| -rw-r--r-- | src/components/chat/chat.js | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/components/chat/chat.js b/src/components/chat/chat.js index 02f3a2f2..9f6e64e3 100644 --- a/src/components/chat/chat.js +++ b/src/components/chat/chat.js @@ -43,6 +43,7 @@ const Chat = { }, created () { this.startFetching() + window.addEventListener('resize', this.handleResize) }, mounted () { window.addEventListener('scroll', this.handleScroll) @@ -132,7 +133,7 @@ const Chat = { } }) }, - // Preserves the scroll position when OSK appears or the posting form changes its height. + // "Sticks" scroll to bottom instead of top, helps with OSK resizing the viewport handleResize (opts = {}) { const { expand = false, delayed = false } = opts @@ -144,15 +145,14 @@ const Chat = { } this.$nextTick(() => { - const { scrollHeight = undefined } = this.lastScrollPosition - this.lastScrollPosition = getScrollPosition() - - const diff = this.lastScrollPosition.scrollHeight - scrollHeight - if (diff > 0 || (!this.bottomedOut() && expand)) { + const { offsetHeight = undefined } = getScrollPosition() + const diff = this.lastScrollPosition.offsetHeight - offsetHeight + if (diff !== 0 || (!this.bottomedOut() && expand)) { this.$nextTick(() => { window.scrollTo({ top: window.scrollY + diff }) }) } + this.lastScrollPosition = getScrollPosition() }) }, scrollDown (options = {}) { |
