diff --git a/client/components/Search/Search.vue b/client/components/Search/Search.vue index 7d3700a..1d61712 100644 --- a/client/components/Search/Search.vue +++ b/client/components/Search/Search.vue @@ -268,7 +268,7 @@
-
+
@@ -908,6 +908,7 @@ class Search { onScroll() { const curScrollTop = this.$refs.scroller.scrollTop; + const toolpanelviewportoffset= this.$refs.toolPanel.getBoundingClientRect().top; if (this.ignoreScrolling) { this.lastScrollTop = curScrollTop; @@ -916,24 +917,29 @@ class Search { return; } + + if (this.lastScrollTop==curScrollTop) return; //если событие вызвано более 1 раза на 1 скролл + if (!this.lastScrollTop) this.lastScrollTop = 0; - if (!this.lastScrollTop2) - this.lastScrollTop2 = 0; - - if (curScrollTop - this.lastScrollTop > 0) { - this.$refs.toolPanel.style.position = 'relative'; - if (this.lastScrollTop2 <= curScrollTop - this.$refs.toolPanel.clientHeight) - this.lastScrollTop2 = 0; - - this.$refs.toolPanel.style.top = `${this.lastScrollTop2}px`; - } else { - this.$refs.toolPanel.style.position = 'sticky'; - this.$refs.toolPanel.style.top = 0; - this.lastScrollTop2 = curScrollTop; - } + 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"; + + } + } this.lastScrollTop = curScrollTop; + + } async ignoreScroll(ms = 300) { @@ -948,6 +954,8 @@ class Search { scrollToTop() { this.$refs.scroller.scrollTop = 0; this.lastScrollTop = 0; + this.$refs.toolPanel.style.top="0px"; + this.$refs.toolPanel.style.position="sticky"; } updatePageCount() {