mirror of
https://github.com/shoelace-style/webawesome.git
synced 2026-01-12 12:09:26 +00:00
add parseDuration method
This commit is contained in:
@@ -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.
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user