aboutsummaryrefslogtreecommitdiff
path: root/src/lib/dom.ts
blob: 0b6a0ab5d2390698fc110cb143b6f740d1c99733 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
export function show(elements: Element[]): void {
  document.body.innerHTML = ''
  elements.forEach(element => document.body.appendChild(element))
}

/* Trigger animation in any case.
 *
 * Trigger reflow between removing and adding the classname.
 * See https://css-tricks.com/restart-css-animation/
 */
export function triggerAnimation(element: HTMLElement, animation: string) {
  element.classList.remove(animation)
  void element.offsetWidth
  element.classList.add(animation)
}