15 lines
349 B
JavaScript
15 lines
349 B
JavaScript
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();
|
|
};
|
|
}
|
|
);
|