From bef48be5712adb32f42cd68b9cda3f43f8c0dc2d Mon Sep 17 00:00:00 2001
From: HEXIANG <869411657@qq.com>
Date: Tue, 18 Jul 2023 12:48:36 +0800
Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E6=94=B9=E8=BE=B9=E6=A0=8F?=
=?UTF-8?q?=E7=9B=AE=E5=BD=95=E6=BB=9A=E5=8A=A8=E6=95=88=E6=9E=9C?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
public/site/zh/help.html | 64 ++++++++++++++++++++++++++++++----------
1 file changed, 49 insertions(+), 15 deletions(-)
diff --git a/public/site/zh/help.html b/public/site/zh/help.html
index 6daa0f939..fd3daf35e 100644
--- a/public/site/zh/help.html
+++ b/public/site/zh/help.html
@@ -271,7 +271,7 @@
-
+
-
基本
@@ -778,23 +778,57 @@ const closeHelpDraweHandle = ()=>{
// const anchorLinks = document.querySelectorAll(".help-a");
// // 监听页面滚动事件
window.addEventListener('scroll',scrollHandler)
+
+function getAllDataIds(parentId) {
+ let parentElement = document.getElementById(parentId);
+ if (parentElement) {
+ let elementsWithDataId = parentElement.querySelectorAll("[data-id]");
+ let dataIds = [];
+ for (let i = 0; i < elementsWithDataId.length; i++) {
+ let dataId = elementsWithDataId[i].getAttribute("data-id");
+ dataIds.push(dataId);
+ }
+ return dataIds;
+ }
+ return [];
+}
+
+let allDataIds = getAllDataIds("help-l-ul");
+let arrOffsetTop = []
+allDataIds.map(item=>{
+ let id = document.getElementById(`${item}`);
+ arrOffsetTop.push(id.offsetTop)
+})
+
function scrollHandler(){
// 遍历导航链接元素
- tabItems.forEach((link,index) => {
- const sectionId = link.getAttribute('data-id'); // 获取锚点ID
- const section = document.querySelector(`#${sectionId}`); // 获取对应的锚点元素
- if (
- section &&
- section.getBoundingClientRect().top>=110&§ion.getBoundingClientRect().top<=150
- ) {
- rm()
- link.classList.add('active');
+ allDataIds.map(item=>{
+ let elements = document.querySelectorAll("[data-id='" + item + "']");
+ elements[0].classList.remove("active");
+ })
+ for (let i = 0; i < arrOffsetTop.length; i++) {
+ if (arrOffsetTop[i] > window.scrollY){
+ let elementsWithDataId = document.querySelectorAll("[data-id='" + `section-${i}` + "']");
+ elementsWithDataId[0].classList.add("active");
+ return;
+ }
}
- if(section &&index===0&§ion.getBoundingClientRect().top>150){
- rm()
- link.classList.add('active')
- }
- });
+ // tabItems.forEach((link,index) => {
+ //
+ // let sectionId = link.getAttribute('data-id'); // 获取锚点ID
+ // let section = document.querySelector(`#${sectionId}`); // 获取对应的锚点元素
+ // if (
+ // section &&
+ // section.offsetTop>=110&§ion.offsetTop<=150
+ // ) {
+ // rm()
+ // link.classList.add('active');
+ // }
+ // if( section &&index===0 && section.offsetTop>150){
+ // rm()
+ // link.classList.add('active')
+ // }
+ // });
}