diff --git a/src/scripts/Lenis.ts b/src/scripts/Lenis.ts index 9213453..c0bbc21 100644 --- a/src/scripts/Lenis.ts +++ b/src/scripts/Lenis.ts @@ -1,8 +1,31 @@ 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({ - 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) => { (window as any).vhlenis.raf(time)