From 51c026e9d2c0e862bc280dcbafe53ae9f55c82b6 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Fri, 13 Jan 2023 17:30:11 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9A=D0=BE=D1=81=D0=BC=D0=B5=D1=82=D0=B8?= =?UTF-8?q?=D1=87=D0=B5=D1=81=D0=BA=D0=B8=D0=B5=20=D0=BF=D0=BE=D0=BF=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/components/Search/Search.vue | 45 ++++++++++++++--------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/client/components/Search/Search.vue b/client/components/Search/Search.vue index 1d61712..57abbb3 100644 --- a/client/components/Search/Search.vue +++ b/client/components/Search/Search.vue @@ -908,7 +908,7 @@ class Search { onScroll() { const curScrollTop = this.$refs.scroller.scrollTop; - const toolpanelviewportoffset= this.$refs.toolPanel.getBoundingClientRect().top; + const toolPanelOffset = this.$refs.toolPanel.getBoundingClientRect().top; if (this.ignoreScrolling) { this.lastScrollTop = curScrollTop; @@ -917,45 +917,44 @@ class Search { return; } - - if (this.lastScrollTop==curScrollTop) return; //если событие вызвано более 1 раза на 1 скролл + if (this.lastScrollTop === curScrollTop) + return; //если событие вызвано более 1 раза на 1 скролл if (!this.lastScrollTop) this.lastScrollTop = 0; - if (curScrollTop - this.lastScrollTop > 0) { //страницу крутят вверх - if (this.$refs.toolPanel.style.position=="sticky") //Если блок приклеен к окну - this.$refs.toolPanel.style.top=`${curScrollTop}px`;//Приклеиваем его к позиции в родителе - this.$refs.toolPanel.style.position="relative"; - if (toolpanelviewportoffset<-this.$refs.toolPanel.offsetHeight) //Но не даём блоку оказаться дальше своей высоты за экраном - this.$refs.toolPanel.style.top = `${curScrollTop-this.$refs.toolPanel.offsetHeight}px`; - } else { - if (toolpanelviewportoffset>=0) - { - this.$refs.toolPanel.style.top="0px"; - this.$refs.toolPanel.style.position="sticky"; - - } - } + if (curScrollTop - this.lastScrollTop > 0) { //страницу крутят вверх + if (this.$refs.toolPanel.style.position == 'sticky') //если блок приклеен к окну + this.$refs.toolPanel.style.top = `${this.lastScrollTop}px`;//приклеиваем его к позиции в родителе + + this.$refs.toolPanel.style.position = 'relative'; + (async() => {//"отложенная" коректировка, из-за артефактов в firefox + if (toolPanelOffset < -this.$refs.toolPanel.offsetHeight) { //не даём блоку оказаться дальше своей высоты за экраном + await utils.sleep(10); + this.$refs.toolPanel.style.top = `${curScrollTop - this.$refs.toolPanel.offsetHeight}px`; + } + })(); + + } else if (toolPanelOffset >= 0) { + this.$refs.toolPanel.style.top = '0px'; + this.$refs.toolPanel.style.position = 'sticky'; + } + this.lastScrollTop = curScrollTop; - - } async ignoreScroll(ms = 300) { this.ignoreScrolling = true; await utils.sleep(ms); await this.$nextTick(); - await this.$nextTick(); - await this.$nextTick(); this.ignoreScrolling = false; } scrollToTop() { this.$refs.scroller.scrollTop = 0; this.lastScrollTop = 0; - this.$refs.toolPanel.style.top="0px"; - this.$refs.toolPanel.style.position="sticky"; + this.$refs.toolPanel.style.top = '0px'; + this.$refs.toolPanel.style.position = 'sticky'; } updatePageCount() {