优化并添加阻尼滚动开关✅

This commit is contained in:
Han
2025-03-09 12:18:18 +08:00
parent 60c91c5989
commit 0b158b7e7a
5 changed files with 11 additions and 6 deletions
+2
View File
@@ -50,4 +50,6 @@ export default {
// 文章页广告(不填不开启)
articleAD_Slot: `<ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-xxxxxx" data-ad-slot="xxxxxx" data-ad-format="auto" data-full-width-responsive="true"></ins>`
},
// 阻尼滚动效果开关
LenisScroll: true
}
+1 -1
View File
@@ -15,7 +15,7 @@ const scrollChangeFn = () => {
const backTopFn = () => {
(window as any).vhlenis && (window as any).vhlenis.stop();
window.scrollTo({ top: 0, behavior: "smooth" });
(window as any).vhlenis.start();
(window as any).vhlenis && (window as any).vhlenis.start();
};
// 页面更新,初始化函数======
// 回顶部DOM
+2 -4
View File
@@ -1,6 +1,4 @@
import { inRouter, outRouter } from "../utils/updateRouter";
// 鼠标滚动阻尼效果
import LenisInit from './Lenis';
// 初始化文章代码块
import codeInit from "../scripts/Code";
// 初始化视频播放器
@@ -31,7 +29,7 @@ import initMobileSidebar from "../scripts/MobileSidebar";
import GoogleAdInit from "../scripts/GoogleAd";
// Han Analytics 统计
import SITE_INFO from "../config";
const { HanAnalytics } = SITE_INFO;
const { HanAnalytics, LenisScroll } = SITE_INFO;
import { LoadScript } from "../utils/index";
// ============================================================
@@ -41,7 +39,7 @@ const videoList: any[] = [];
const MusicList: any[] = [];
const indexInit = async (only: boolean = true) => {
// 鼠标滚动阻尼效果
only && LenisInit();
LenisScroll && only && (await import('./Lenis')).default();
// 预加载搜索数据
only && searchFn("");
// 初始化搜索功能
+1 -1
View File
@@ -16,7 +16,7 @@ let clearTimer: any = null;
(window as any).vhlenis.stop();
clearTimer = setTimeout(() => {
(window as any).vhlenis.start();
}, 566);
}, 288);
}
} catch {
scrollStatus = null;