meilisearch-admin/app/modifiers/animate.js

16 lines
349 B
JavaScript
Raw Normal View History

2022-09-14 09:55:48 +00:00
import { modifier } from 'ember-modifier';
export default modifier(
(element, [keyframes, timing], { onFinish, onCancel }) => {
const animation = element.animate(keyframes, timing);
animation.finished
.then(() => onFinish?.())
.catch((error) => onCancel?.(error));
return () => {
animation.cancel();
};
}
);