Косметические поправки
This commit is contained in:
@@ -908,7 +908,7 @@ class Search {
|
|||||||
|
|
||||||
onScroll() {
|
onScroll() {
|
||||||
const curScrollTop = this.$refs.scroller.scrollTop;
|
const curScrollTop = this.$refs.scroller.scrollTop;
|
||||||
const toolpanelviewportoffset= this.$refs.toolPanel.getBoundingClientRect().top;
|
const toolPanelOffset = this.$refs.toolPanel.getBoundingClientRect().top;
|
||||||
|
|
||||||
if (this.ignoreScrolling) {
|
if (this.ignoreScrolling) {
|
||||||
this.lastScrollTop = curScrollTop;
|
this.lastScrollTop = curScrollTop;
|
||||||
@@ -917,45 +917,44 @@ class Search {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.lastScrollTop === curScrollTop)
|
||||||
if (this.lastScrollTop==curScrollTop) return; //если событие вызвано более 1 раза на 1 скролл
|
return; //если событие вызвано более 1 раза на 1 скролл
|
||||||
|
|
||||||
if (!this.lastScrollTop)
|
if (!this.lastScrollTop)
|
||||||
this.lastScrollTop = 0;
|
this.lastScrollTop = 0;
|
||||||
|
|
||||||
if (curScrollTop - this.lastScrollTop > 0) { //страницу крутят вверх
|
if (curScrollTop - this.lastScrollTop > 0) { //страницу крутят вверх
|
||||||
if (this.$refs.toolPanel.style.position=="sticky") //Если блок приклеен к окну
|
if (this.$refs.toolPanel.style.position == 'sticky') //если блок приклеен к окну
|
||||||
this.$refs.toolPanel.style.top=`${curScrollTop}px`;//Приклеиваем его к позиции в родителе
|
this.$refs.toolPanel.style.top = `${this.lastScrollTop}px`;//приклеиваем его к позиции в родителе
|
||||||
this.$refs.toolPanel.style.position="relative";
|
|
||||||
if (toolpanelviewportoffset<-this.$refs.toolPanel.offsetHeight) //Но не даём блоку оказаться дальше своей высоты за экраном
|
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`;
|
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";
|
|
||||||
|
|
||||||
|
} else if (toolPanelOffset >= 0) {
|
||||||
|
this.$refs.toolPanel.style.top = '0px';
|
||||||
|
this.$refs.toolPanel.style.position = 'sticky';
|
||||||
}
|
}
|
||||||
}
|
|
||||||
this.lastScrollTop = curScrollTop;
|
this.lastScrollTop = curScrollTop;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async ignoreScroll(ms = 300) {
|
async ignoreScroll(ms = 300) {
|
||||||
this.ignoreScrolling = true;
|
this.ignoreScrolling = true;
|
||||||
await utils.sleep(ms);
|
await utils.sleep(ms);
|
||||||
await this.$nextTick();
|
await this.$nextTick();
|
||||||
await this.$nextTick();
|
|
||||||
await this.$nextTick();
|
|
||||||
this.ignoreScrolling = false;
|
this.ignoreScrolling = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
scrollToTop() {
|
scrollToTop() {
|
||||||
this.$refs.scroller.scrollTop = 0;
|
this.$refs.scroller.scrollTop = 0;
|
||||||
this.lastScrollTop = 0;
|
this.lastScrollTop = 0;
|
||||||
this.$refs.toolPanel.style.top="0px";
|
this.$refs.toolPanel.style.top = '0px';
|
||||||
this.$refs.toolPanel.style.position="sticky";
|
this.$refs.toolPanel.style.position = 'sticky';
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePageCount() {
|
updatePageCount() {
|
||||||
|
|||||||
Reference in New Issue
Block a user