This repository has been archived on 2022-05-10. You can view files and clone it, but cannot push or open issues or pull requests.
2020-06-18 09:49:48 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2020-06-21 17:16:01 +00:00
|
|
|
export function nextAnimationFrame(): Promise<void> {
|
|
|
|
return new Promise((resolve) => requestAnimationFrame(() => resolve()));
|
|
|
|
}
|
|
|
|
|
|
|
|
export default { findParent, nextAnimationFrame };
|