2021-04-23 08:33:33 +02:00
|
|
|
import { Directive } from 'vue';
|
2021-11-11 18:02:25 +01:00
|
|
|
import { defaultStore } from '@/store';
|
2021-04-23 08:33:33 +02:00
|
|
|
|
|
|
|
export default {
|
2022-12-31 11:46:16 +01:00
|
|
|
mounted(el: HTMLElement, binding, vn) {
|
2021-09-23 16:01:32 +02:00
|
|
|
if (!defaultStore.state.animation) return;
|
|
|
|
|
2022-12-31 11:46:16 +01:00
|
|
|
const target = el.children[0];
|
|
|
|
|
|
|
|
if (target == null) return;
|
|
|
|
|
|
|
|
target.classList.add('_anime_bounce_standBy');
|
2021-04-24 11:38:38 +02:00
|
|
|
|
2021-04-23 08:33:33 +02:00
|
|
|
el.addEventListener('mousedown', () => {
|
2022-12-31 11:46:16 +01:00
|
|
|
target.classList.add('_anime_bounce_standBy');
|
|
|
|
target.classList.add('_anime_bounce_ready');
|
2021-04-23 08:33:33 +02:00
|
|
|
|
2022-12-31 11:46:16 +01:00
|
|
|
target.addEventListener('mouseleave', () => {
|
|
|
|
target.classList.remove('_anime_bounce_ready');
|
2021-04-23 08:33:33 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
el.addEventListener('click', () => {
|
2022-12-31 11:46:16 +01:00
|
|
|
target.classList.add('_anime_bounce');
|
2021-04-23 08:33:33 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
el.addEventListener('animationend', () => {
|
2022-12-31 11:46:16 +01:00
|
|
|
target.classList.remove('_anime_bounce_ready');
|
|
|
|
target.classList.remove('_anime_bounce');
|
|
|
|
target.classList.add('_anime_bounce_standBy');
|
2021-04-23 08:33:33 +02:00
|
|
|
});
|
2022-12-22 08:01:59 +01:00
|
|
|
},
|
2021-04-23 08:33:33 +02:00
|
|
|
} as Directive;
|