feat: cursor following page scrolling #229

This commit is contained in:
Hufe921
2023-08-04 20:38:22 +08:00
parent a96a77a237
commit 3db28cc04f
8 changed files with 91 additions and 7 deletions
+16
View File
@@ -219,3 +219,19 @@ export function convertStringToBase64(input: string) {
const base64 = window.btoa(charArray.join(''))
return base64
}
export function findScrollContainer(element: HTMLElement) {
let parent = element.parentElement
while (parent) {
const style = window.getComputedStyle(parent)
const overflowY = style.getPropertyValue('overflow-y')
if (
parent.scrollHeight > parent.clientHeight &&
(overflowY === 'auto' || overflowY === 'scroll')
) {
return parent
}
parent = parent.parentElement
}
return document.documentElement
}