add parseDuration method

pull/463/head
Cory LaViska 2021-05-26 12:41:52 -04:00
rodzic 8776c3f4a8
commit 3fce846a8d
1 zmienionych plików z 17 dodań i 0 usunięć

Wyświetl plik

@ -18,6 +18,23 @@ export function animateTo(el: HTMLElement, keyframes: Keyframe[], options?: Keyf
});
}
//
// Parses a CSS duration and returns the number of milliseconds.
//
export function parseDuration(delay: number | string) {
delay = (delay + '').toLowerCase();
if (delay.indexOf('ms') > -1) {
return parseFloat(delay);
}
if (delay.indexOf('s') > -1) {
return parseFloat(delay) * 1000;
}
return parseFloat(delay);
}
//
// Tells if the user has enabled the "reduced motion" setting in their browser or OS.
//