forked from hamcha/tghandbook
20 lines
434 B
TypeScript
20 lines
434 B
TypeScript
export function nextAnimationFrame(): Promise {
|
|
return new Promise(requestAnimationFrame);
|
|
}
|
|
|
|
export function findParent(
|
|
base: HTMLElement,
|
|
matchFn: (candidate: HTMLElement) => boolean
|
|
): HTMLElement | null {
|
|
let parent = base.parentElement;
|
|
while (parent != null) {
|
|
if (matchFn(parent)) {
|
|
break;
|
|
}
|
|
parent = parent.parentElement;
|
|
}
|
|
return parent;
|
|
}
|
|
|
|
export default { nextAnimationFrame, findParent };
|