|
@@ -53,6 +53,7 @@ export default {
|
|
|
childrenHeight += ele.children.length * 30;
|
|
|
}
|
|
|
});
|
|
|
+ console.log(childrenHeight + 30 * this.data.length - 20 + "px")
|
|
|
return (childrenHeight + 30) * (this.data.length - 20) + "px";
|
|
|
},
|
|
|
//获取所有锚点组合的位置
|
|
@@ -140,14 +141,17 @@ export default {
|
|
|
}
|
|
|
//当前滚动位置
|
|
|
let scrollTop = this.$refs["anchor-body"].scrollTop;
|
|
|
+ // console.log(scrollTop)
|
|
|
+
|
|
|
this.allAnchor.forEach((ele, i) => {
|
|
|
let dom = document.querySelector(ele.tar);
|
|
|
if (dom) {
|
|
|
if (
|
|
|
- scrollTop > dom.offsetTop &&
|
|
|
- scrollTop <= dom.offsetTop + dom.offsetHeight / 3
|
|
|
+ scrollTop > dom.offsetTop-80
|
|
|
+
|
|
|
) {
|
|
|
this.currentAnchor = ele.tar;
|
|
|
+ // this.currentAnchor = this.allAnchor[i+1].tar;
|
|
|
// this.$refs["anchor-icon"].style.display = "block";
|
|
|
// this.$refs["anchor-icon"].style.top = i * 30 + 2 + "px";
|
|
|
return;
|
|
@@ -210,6 +214,7 @@ export default {
|
|
|
border-radius: 1px;
|
|
|
position: relative;
|
|
|
background-color: lightgrey;
|
|
|
+ display: none;
|
|
|
.anchor-icon {
|
|
|
position: absolute;
|
|
|
width: 8px;
|