34 lines
856 B
TypeScript
34 lines
856 B
TypeScript
import { Directive } from 'vue';
|
|
import { defaultStore } from '@/store';
|
|
|
|
export default {
|
|
mounted(el: HTMLElement, binding, vn) {
|
|
if (!defaultStore.state.animation) return;
|
|
|
|
const target = el.children[0];
|
|
|
|
if (target == null) return;
|
|
|
|
target.classList.add('_anime_bounce_standBy');
|
|
|
|
el.addEventListener('mousedown', () => {
|
|
target.classList.add('_anime_bounce_standBy');
|
|
target.classList.add('_anime_bounce_ready');
|
|
|
|
target.addEventListener('mouseleave', () => {
|
|
target.classList.remove('_anime_bounce_ready');
|
|
});
|
|
});
|
|
|
|
el.addEventListener('click', () => {
|
|
target.classList.add('_anime_bounce');
|
|
});
|
|
|
|
el.addEventListener('animationend', () => {
|
|
target.classList.remove('_anime_bounce_ready');
|
|
target.classList.remove('_anime_bounce');
|
|
target.classList.add('_anime_bounce_standBy');
|
|
});
|
|
},
|
|
} as Directive;
|