tghandbook/src/utils.ts

20 lines
434 B
TypeScript
Raw Normal View History

2020-06-20 15:13:49 +00:00
export function nextAnimationFrame(): Promise {
return new Promise(requestAnimationFrame);
}
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-20 15:13:49 +00:00
export default { nextAnimationFrame, findParent };