summaryrefslogtreecommitdiff
path: root/src/client/directives/particle.ts
blob: 4fb2a7948e875278e37ded0bd14866fb69cef557 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import Particle from '../components/particle.vue';

export default {
	bind(el, binding, vn) {
		// 明示的に false であればバインドしない
		if (binding.value === false) return;
		el.addEventListener('click', () => {
			const rect = el.getBoundingClientRect();

			const x = rect.left + (el.clientWidth / 2);
			const y = rect.top + (el.clientHeight / 2);

			const particle = new Particle({
				parent: vn.context,
				propsData: {
					x,
					y
				}
			}).$mount();

			document.body.appendChild(particle.$el);
		});
	}
};