优化Lenis
This commit is contained in:
parent
ae1bcf555d
commit
60c91c5989
@ -1,8 +1,31 @@
|
|||||||
import Lenis from "lenis";
|
import Lenis from "lenis";
|
||||||
|
|
||||||
const IncludeClassName = ['vh-code-box', 'vh-search-list'];
|
const IncludeClassName = ['.vh-search.active .vh-search-list', '.aplayer-list>ol', '.vh-code-box>pre'];
|
||||||
|
let scrollStatus: any = null;
|
||||||
|
let clearTimer: any = null;
|
||||||
(window as any).vhlenis = new Lenis({
|
(window as any).vhlenis = new Lenis({
|
||||||
prevent: (node) => IncludeClassName.some((i: string) => node.className.includes(i))
|
prevent: (node) => {
|
||||||
|
const res = IncludeClassName.some((i: string) => {
|
||||||
|
if (node.querySelector('main') || (node.tagName.toLowerCase() === 'main' && !node.parentElement!.classList.contains('active'))) return null;
|
||||||
|
scrollStatus = node.querySelector(i) ? node : null;
|
||||||
|
if (i.includes('vh-code-box>pre')) {
|
||||||
|
try {
|
||||||
|
scrollStatus = (node.querySelector(i)!.clientHeight == 888) ? node : null;
|
||||||
|
if (node.querySelector(i)!.clientHeight == 888) {
|
||||||
|
clearTimeout(clearTimer);
|
||||||
|
(window as any).vhlenis.stop();
|
||||||
|
clearTimer = setTimeout(() => {
|
||||||
|
(window as any).vhlenis.start();
|
||||||
|
}, 566);
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
scrollStatus = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return scrollStatus;
|
||||||
|
})
|
||||||
|
return res;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
const lenisInit = (time: any) => {
|
const lenisInit = (time: any) => {
|
||||||
(window as any).vhlenis.raf(time)
|
(window as any).vhlenis.raf(time)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user