UNPKG

svooltip

Version:

A basic Svelte tooltip directive. Powered by [Floating UI](https://floating-ui.com/).

25 lines (24 loc) 617 B
let id = 1; export const animate = async (add, remove, tooltip) => { return new Promise((resolve) => { tooltip?.classList.add(add); tooltip?.classList.remove(remove); tooltip?.addEventListener('animationend', () => { tooltip?.classList.remove(add); resolve(); }); }); }; export const wait = (time, fn) => { clearWait(fn); return new Promise((resolve) => { setTimeout(() => { clearWait(fn); resolve(); }, time); }); }; export const ID = () => id++; const clearWait = (fn) => { clearTimeout(fn); };