项洋 1 month ago
commit 5f709949ba

@ -141,7 +141,6 @@
:visibility-height="200"
:bottom="50"
:right="10"
title="返回顶部"
style="z-index: 1000; border: 1px solid #2b62f1"
>
</el-backtop>
@ -290,6 +289,7 @@ export default {
},
projectRemarks: [],
loading: false,
scrollTimeout: null,
};
},
created() {
@ -474,28 +474,34 @@ export default {
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
},
handleScroll() {
//
const container = document.querySelector(".containerbody");
if (!container) return;
//
const scrollPosition = container.scrollTop; //
//
for (let i = this.sections.length - 1; i >= 0; i--) {
const element = document.getElementById(this.sections[i].id);
if (element) {
//
const elementPosition = element.offsetTop - container.offsetTop;
if (elementPosition <= scrollPosition) {
if (this.activeSection !== this.sections[i].id) {
this.activeSection = this.sections[i].id;
if (this.scrollTimeout) {
clearTimeout(this.scrollTimeout);
}
this.scrollTimeout = setTimeout(() => {
const scrollPosition = container.scrollTop;
if (scrollPosition > this.lastScrollTop) {
this.scrollDirection = 'down';
} else {
this.scrollDirection = 'up';
}
this.lastScrollTop = scrollPosition;
const offset = this.scrollDirection === 'down' ? 500 : 200;
const adjustedScrollPosition = scrollPosition + offset;
for (let i = this.sections.length - 1; i >= 0; i--) {
const element = document.getElementById(this.sections[i].id);
if (element) {
const elementPosition = element.offsetTop - container.offsetTop;
if (elementPosition <= adjustedScrollPosition) {
if (this.activeSection !== this.sections[i].id) {
this.activeSection = this.sections[i].id;
}
break;
}
break;
}
}
}
}, 50);
},
handleMenuClick() {
if (this.$refs.menuRef) {

@ -146,7 +146,6 @@
:visibility-height="200"
:bottom="50"
:right="10"
title="返回顶部"
style="z-index: 1000"
>
</el-backtop>

Loading…
Cancel
Save