From 2df48b16438a5bfaa2650657f605cc58a540abac Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Sun, 10 Apr 2022 17:47:54 +0300 Subject: [PATCH 1/9] revert timeline changes --- src/components/timeline/timeline.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/components/timeline/timeline.js b/src/components/timeline/timeline.js index bfee2382a..a3931d323 100644 --- a/src/components/timeline/timeline.js +++ b/src/components/timeline/timeline.js @@ -12,8 +12,6 @@ library.add( faCog ) -const scroller = () => document.getElementById('content') - const Timeline = { props: [ 'timeline', @@ -91,7 +89,7 @@ const Timeline = { const credentials = store.state.users.currentUser.credentials const showImmediately = this.timeline.visibleStatuses.length === 0 - scroller() && scroller().addEventListener('scroll', this.handleScroll) + window.addEventListener('scroll', this.handleScroll) if (store.state.api.fetchers[this.timelineName]) { return false } @@ -113,7 +111,7 @@ const Timeline = { setTimeout(this.determineVisibleStatuses, 250) }, unmounted () { - scroller().removeEventListener('scroll', this.handleScroll) + window.removeEventListener('scroll', this.handleScroll) window.removeEventListener('keydown', this.handleShortKey) if (typeof document.hidden !== 'undefined') document.removeEventListener('visibilitychange', this.handleVisibilityChange, false) this.$store.commit('setLoading', { timeline: this.timelineName, value: false }) @@ -143,7 +141,7 @@ const Timeline = { this.$store.commit('showNewStatuses', { timeline: this.timelineName }) this.paused = false } - scroller().scrollTop = 0 + window.scrollTop = 0 }, fetchOlderStatuses: throttle(function () { const store = this.$store @@ -231,8 +229,8 @@ const Timeline = { } if (count > 0) { // only 'stream' them when you're scrolled to the top - const doc = document.getElementById('content') - const top = (doc.scrollTop) - (doc.clientTop || 0) + const doc = document.documentElement + const top = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0) if (top < 15 && !this.paused && !(this.unfocused && this.$store.getters.mergedConfig.pauseOnUnfocused) From 77505fa7c9f9188ab224e46fafcf5163a45f732b Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Sun, 10 Apr 2022 17:48:02 +0300 Subject: [PATCH 2/9] revert layout back to scrollable body --- src/App.scss | 43 ++++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/src/App.scss b/src/App.scss index 678c44104..590c053fc 100644 --- a/src/App.scss +++ b/src/App.scss @@ -1,16 +1,15 @@ // stylelint-disable rscss/class-format @import './_variables.scss'; +:root { + --navbar-height: 50px; +} + html { font-size: 14px; - overflow: hidden; - max-height: 100vh; } body { - overflow: hidden; - max-height: 100vh; - max-width: 100vw; font-family: sans-serif; font-family: var(--interfaceFont, sans-serif); margin: 0; @@ -19,6 +18,7 @@ body { overflow-x: hidden; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; + overscroll-behavior-y: none; &.hidden { display: none; @@ -26,6 +26,10 @@ body { } @media (any-pointer: fine) { + body { + background: var(--bg); + } + * { scrollbar-color: var(--btn) transparent; @@ -106,35 +110,25 @@ nav { box-shadow: var(--topBarShadow); box-sizing: border-box; height: var(--navbar-height); -} - -#app-loaded { - min-height: 100vh; - min-width: 100vw; - overflow: hidden; - - --navbar-height: 50px; -} - -#content { - overscroll-behavior-y: none; - overflow-y: scroll; - overflow-x: hidden; - position: sticky; + position: fixed; } #sidebar { grid-area: sidebar; + top: var(--navbar-height); + position: sticky; +} + +#main-scroller { + top: var(--navbar-height); + grid-area: content; + position: relative; } #notifs-column { grid-area: notifs; } -#main-scroller { - grid-area: content; -} - .app-bg-wrapper { position: fixed; height: 100%; @@ -175,7 +169,6 @@ nav { grid-template-rows: 1fr; box-sizing: border-box; margin: 0 auto; - height: calc(100vh - var(--navbar-height)); align-content: flex-start; flex-wrap: wrap; padding: 0 10px; From 4c2301bc9f07bbc2ffd3d715311d8980912fc9df Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Sun, 10 Apr 2022 18:43:52 +0300 Subject: [PATCH 3/9] fix scrollable columns --- src/App.scss | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/App.scss b/src/App.scss index 590c053fc..8f3910700 100644 --- a/src/App.scss +++ b/src/App.scss @@ -115,6 +115,9 @@ nav { #sidebar { grid-area: sidebar; +} + +.column.-scrollable { top: var(--navbar-height); position: sticky; } @@ -192,7 +195,7 @@ nav { padding-top: 10px; position: sticky; - top: 0; + top: var(--navbar-height); max-height: calc(100vh - var(--navbar-height)); overflow-y: auto; overflow-x: hidden; From a035fa4e6cca657c464b472c0bfd479197cc7f7e Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Sun, 10 Apr 2022 18:44:03 +0300 Subject: [PATCH 4/9] fix timeline scroll-to-top --- src/components/timeline/timeline.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/timeline/timeline.js b/src/components/timeline/timeline.js index a3931d323..4ae7410e0 100644 --- a/src/components/timeline/timeline.js +++ b/src/components/timeline/timeline.js @@ -141,7 +141,7 @@ const Timeline = { this.$store.commit('showNewStatuses', { timeline: this.timelineName }) this.paused = false } - window.scrollTop = 0 + window.scrollTo({ top: 0 }) }, fetchOlderStatuses: throttle(function () { const store = this.$store From 7426417a525b30aa25a95bb64899c95df6ebf080 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Sun, 10 Apr 2022 18:44:22 +0300 Subject: [PATCH 5/9] more fixes --- src/panel.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/panel.scss b/src/panel.scss index bd56858ff..049144ba1 100644 --- a/src/panel.scss +++ b/src/panel.scss @@ -63,7 +63,7 @@ &.-sticky { position: sticky; - top: 0; + top: var(--navbar-height); z-index: 2; } From 5b664f464d2aa0121a372dd8b14e26160b6dad5c Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Sun, 10 Apr 2022 19:28:26 +0300 Subject: [PATCH 6/9] chat fixes --- src/components/chat/chat.js | 66 +++++------------------- src/components/chat/chat.vue | 1 - src/components/chat/chat_layout_utils.js | 27 ++++------ src/components/chat_new/chat_new.vue | 1 - 4 files changed, 21 insertions(+), 74 deletions(-) diff --git a/src/components/chat/chat.js b/src/components/chat/chat.js index 5d2c1d095..a2789d2e0 100644 --- a/src/components/chat/chat.js +++ b/src/components/chat/chat.js @@ -19,8 +19,6 @@ library.add( faChevronLeft ) -const scroller = () => document.getElementById('content') - const BOTTOMED_OUT_OFFSET = 10 const JUMP_TO_BOTTOM_BUTTON_VISIBILITY_OFFSET = 10 const SAFE_RESIZE_TIME_OFFSET = 100 @@ -45,10 +43,9 @@ const Chat = { }, created () { this.startFetching() - window.addEventListener('resize', this.handleLayoutChange) }, mounted () { - scroller().addEventListener('scroll', this.handleScroll) + window.addEventListener('scroll', this.handleScroll) if (typeof document.hidden !== 'undefined') { document.addEventListener('visibilitychange', this.handleVisibilityChange, false) } @@ -56,12 +53,9 @@ const Chat = { this.$nextTick(() => { this.handleResize() }) - this.setChatLayout() }, unmounted () { - scroller().removeEventListener('scroll', this.handleScroll) - window.removeEventListener('resize', this.handleLayoutChange) - this.unsetChatLayout() + window.removeEventListener('scroll', this.handleScroll) if (typeof document.hidden !== 'undefined') document.removeEventListener('visibilitychange', this.handleVisibilityChange, false) this.$store.dispatch('clearCurrentChat') }, @@ -97,8 +91,6 @@ const Chat = { ...mapState({ backendInteractor: state => state.api.backendInteractor, mastoUserSocketStatus: state => state.api.mastoUserSocketStatus, - mobileLayout: state => state.interface.mobileLayout, - layoutHeight: state => state.interface.layoutHeight, currentUser: state => state.users.currentUser }) }, @@ -116,9 +108,6 @@ const Chat = { '$route': function () { this.startFetching() }, - layoutHeight () { - this.handleResize({ expand: true }) - }, mastoUserSocketStatus (newValue) { if (newValue === WSConnectionStatus.JOINED) { this.fetchChat({ isFirstFetch: true }) @@ -142,30 +131,6 @@ const Chat = { } }) }, - setChatLayout () { - // This is a hacky way to adjust the global layout to the mobile chat (without modifying the rest of the app). - // This layout prevents empty spaces from being visible at the bottom - // of the chat on iOS Safari (`safe-area-inset`) when - // - the on-screen keyboard appears and the user starts typing - // - the user selects the text inside the input area - // - the user selects and deletes the text that is multiple lines long - // TODO: unify the chat layout with the global layout. - let html = document.querySelector('html') - if (html) { - html.classList.add('chat-layout') - } - }, - unsetChatLayout () { - let html = document.querySelector('html') - if (html) { - html.classList.remove('chat-layout') - } - }, - handleLayoutChange () { - this.$nextTick(() => { - this.scrollDown() - }) - }, // Preserves the scroll position when OSK appears or the posting form changes its height. handleResize (opts = {}) { const { expand = false, delayed = false } = opts @@ -179,25 +144,20 @@ const Chat = { this.$nextTick(() => { const { offsetHeight = undefined } = this.lastScrollPosition - this.lastScrollPosition = getScrollPosition(scroller()) + this.lastScrollPosition = getScrollPosition() const diff = this.lastScrollPosition.offsetHeight - offsetHeight if (diff < 0 || (!this.bottomedOut() && expand)) { this.$nextTick(() => { - scroller().scrollTo({ - top: scroller().scrollTop - diff, - left: 0 - }) + window.scrollTo({ top: window.scrollY - diff }) }) } }) }, scrollDown (options = {}) { const { behavior = 'auto', forceRead = false } = options - const scrollable = scroller() - if (!scrollable) { return } this.$nextTick(() => { - scrollable.scrollTo({ top: scrollable.scrollHeight, left: 0, behavior }) + window.scrollTo({ top: document.documentElement.scrollHeight, behavior }) }) if (forceRead) { this.readChat() @@ -213,11 +173,10 @@ const Chat = { }) }, bottomedOut (offset) { - return isBottomedOut(scroller(), offset) + return isBottomedOut(offset) }, reachedTop () { - const scrollable = scroller() - return scrollable && scrollable.scrollTop <= 0 + return window.scrollY <= 0 }, cullOlderCheck () { window.setTimeout(() => { @@ -248,10 +207,9 @@ const Chat = { } }, 200), handleScrollUp (positionBeforeLoading) { - const positionAfterLoading = getScrollPosition(scroller()) - scroller().scrollTo({ - top: getNewTopPosition(positionBeforeLoading, positionAfterLoading), - left: 0 + const positionAfterLoading = getScrollPosition() + window.scrollTo({ + top: getNewTopPosition(positionBeforeLoading, positionAfterLoading) }) }, fetchChat ({ isFirstFetch = false, fetchLatest = false, maxId }) { @@ -270,7 +228,7 @@ const Chat = { chatService.clear(chatMessageService) } - const positionBeforeUpdate = getScrollPosition(scroller()) + const positionBeforeUpdate = getScrollPosition() this.$store.dispatch('addChatMessages', { chatId, messages }).then(() => { this.$nextTick(() => { if (fetchOlderMessages) { @@ -281,7 +239,7 @@ const Chat = { // full height of the scrollable container. // If this is the case, we want to fetch the messages until the scrollable container // is fully populated so that the user has the ability to scroll up and load the history. - if (!isScrollable(scroller()) && messages.length > 0) { + if (!isScrollable() && messages.length > 0) { this.fetchChat({ maxId: this.currentChatMessageService.minId }) } }) diff --git a/src/components/chat/chat.vue b/src/components/chat/chat.vue index 3b0129fa4..d909bed93 100644 --- a/src/components/chat/chat.vue +++ b/src/components/chat/chat.vue @@ -2,7 +2,6 @@