Perf: use native once listener

This commit is contained in:
Cell
2022-09-10 10:16:04 +08:00
parent 995f9558db
commit c9db04a462
3 changed files with 4 additions and 6 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+2 -4
View File
@@ -28,12 +28,10 @@ class Util {
animateCSS(element, animation, reserved, callback) {
!Array.isArray(animation) && (animation = [animation]);
element.classList.add('animate__animated', ...animation);
const handler = () => {
element.addEventListener('animationend', () => {
!reserved && element.classList.remove('animate__animated', ...animation);
element.removeEventListener('animationend', handler);
typeof callback === 'function' && callback();
};
element.addEventListener('animationend', handler, false);
}, { once: true });
}
/**