|
@@ -4641,16 +4641,37 @@ export default {
|
|
|
} else {
|
|
|
const element = document.getElementById(`${s}+${i}`);
|
|
|
if (element) {
|
|
|
- element.scrollIntoView({
|
|
|
- behavior: 'smooth', block: "start", inline: "nearest"
|
|
|
- },()=>{
|
|
|
+ // element.scrollIntoView({
|
|
|
+ // behavior: 'smooth', block: "start", inline: "nearest"
|
|
|
+ // }, ()=>{
|
|
|
+ // let scrollBody = document.querySelector(".zyBoxC").parentElement
|
|
|
+ // scrollBody.scrollTop = scrollBody.scrollTop - 70
|
|
|
+ // });
|
|
|
+ function scrollToElement(elementA) {
|
|
|
+ return new Promise((resolve) => {
|
|
|
+ const observer = new IntersectionObserver((entries) => {
|
|
|
+ if (entries[0].isIntersecting) {
|
|
|
+ observer.disconnect(); // 停止观察
|
|
|
+ setTimeout(() => {
|
|
|
+ resolve(); // 延迟以确保滚动完成
|
|
|
+ }, 300); // 可以调整延迟时间
|
|
|
+ }
|
|
|
+ }, { threshold: [1] }); // 阈值设为 1 确保完全可见
|
|
|
+
|
|
|
+ elementA.scrollIntoView({ behavior: 'smooth', block: "start" });
|
|
|
+ // elementA.scrollIntoView();
|
|
|
+ observer.observe(elementA);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 使用示例
|
|
|
+ scrollToElement(element).then(()=>{
|
|
|
let scrollBody = document.querySelector(".zyBoxC").parentElement
|
|
|
- scrollBody.scrollTop = scrollBody.scrollTop - 30
|
|
|
+ setTimeout(() => {
|
|
|
+ scrollBody.scrollTop = scrollBody.scrollTop - 70;
|
|
|
+ }, 100); // 调整时间确保足够长
|
|
|
});
|
|
|
- setTimeout(() => {
|
|
|
- let scrollBody = document.querySelector(".zyBoxC").parentElement
|
|
|
- scrollBody.scrollTop = scrollBody.scrollTop - 70
|
|
|
- }, 500);
|
|
|
}
|
|
|
var a = s + "-" + i;
|
|
|
// var b = document.getElementById(a);
|
|
@@ -4669,16 +4690,37 @@ export default {
|
|
|
|
|
|
const element = document.getElementById(`${s}+${i}`);
|
|
|
if (element) {
|
|
|
- element.scrollIntoView({
|
|
|
- behavior: 'smooth', block: "start", inline: "nearest"
|
|
|
- },()=>{
|
|
|
- let scrollBody = document.querySelector(".zyBoxC").parentElement
|
|
|
- scrollBody.scrollTop = scrollBody.scrollTop - 70
|
|
|
- });
|
|
|
- setTimeout(() => {
|
|
|
+ // element.scrollIntoView({
|
|
|
+ // behavior: 'smooth', block: "start", inline: "nearest"
|
|
|
+ // }, ()=>{
|
|
|
+ // let scrollBody = document.querySelector(".zyBoxC").parentElement
|
|
|
+ // scrollBody.scrollTop = scrollBody.scrollTop - 70
|
|
|
+ // });
|
|
|
+ function scrollToElement(elementA) {
|
|
|
+ return new Promise((resolve) => {
|
|
|
+ const observer = new IntersectionObserver((entries) => {
|
|
|
+ if (entries[0].isIntersecting) {
|
|
|
+ observer.disconnect(); // 停止观察
|
|
|
+ setTimeout(() => {
|
|
|
+ resolve(); // 延迟以确保滚动完成
|
|
|
+ }, 300); // 可以调整延迟时间
|
|
|
+ }
|
|
|
+ }, { threshold: [1] }); // 阈值设为 1 确保完全可见
|
|
|
+
|
|
|
+ elementA.scrollIntoView({ behavior: 'smooth', block: "start" });
|
|
|
+ // elementA.scrollIntoView();
|
|
|
+ observer.observe(elementA);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 使用示例
|
|
|
+ scrollToElement(element).then(()=>{
|
|
|
let scrollBody = document.querySelector(".zyBoxC").parentElement
|
|
|
- scrollBody.scrollTop = scrollBody.scrollTop - 70
|
|
|
- }, 500);
|
|
|
+ setTimeout(() => {
|
|
|
+ scrollBody.scrollTop = scrollBody.scrollTop - 70;
|
|
|
+ }, 100); // 调整时间确保足够长
|
|
|
+ });
|
|
|
}
|
|
|
var a = s + "-" + i;
|
|
|
|