项洋 1 month ago
commit 5f709949ba

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

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

Loading…
Cancel
Save