项洋 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,21 +474,26 @@ 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;
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--) { for (let i = this.sections.length - 1; i >= 0; i--) {
const element = document.getElementById(this.sections[i].id); const element = document.getElementById(this.sections[i].id);
if (element) { if (element) {
//
const elementPosition = element.offsetTop - container.offsetTop; const elementPosition = element.offsetTop - container.offsetTop;
if (elementPosition <= adjustedScrollPosition) {
if (elementPosition <= scrollPosition) {
if (this.activeSection !== this.sections[i].id) { if (this.activeSection !== this.sections[i].id) {
this.activeSection = this.sections[i].id; this.activeSection = this.sections[i].id;
} }
@ -496,6 +501,7 @@ export default {
} }
} }
} }
}, 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