egirlskey/src/client/directives/click-anime.ts

30 lines
747 B
TypeScript
Raw Normal View History

2021-04-23 06:33:33 +00:00
import { Directive } from 'vue';
import { defaultStore } from '@client/store';
2021-04-23 06:33:33 +00:00
export default {
mounted(el, binding, vn) {
if (!defaultStore.state.animation) return;
2021-04-24 09:38:38 +00:00
el.classList.add('_anime_bounce_standBy');
2021-04-23 06:33:33 +00:00
el.addEventListener('mousedown', () => {
2021-04-24 09:38:38 +00:00
el.classList.add('_anime_bounce_standBy');
2021-04-23 06:33:33 +00:00
el.classList.add('_anime_bounce_ready');
el.addEventListener('mouseleave', () => {
el.classList.remove('_anime_bounce_ready');
});
});
el.addEventListener('click', () => {
el.classList.add('_anime_bounce');
});
el.addEventListener('animationend', () => {
el.classList.remove('_anime_bounce_ready');
el.classList.remove('_anime_bounce');
2021-04-24 09:38:38 +00:00
el.classList.add('_anime_bounce_standBy');
2021-04-23 06:33:33 +00:00
});
}
} as Directive;