From d4324dc0cbfeb96b33fca246dd90c1851f257651 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 22 Feb 2020 01:20:58 +0900 Subject: [PATCH] Reaction particle --- src/client/components/particle.vue | 54 +++++++++++++++++++++++ src/client/components/reaction-picker.vue | 2 +- src/client/directives/index.ts | 2 + src/client/directives/particle.ts | 22 +++++++++ 4 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 src/client/components/particle.vue create mode 100644 src/client/directives/particle.ts diff --git a/src/client/components/particle.vue b/src/client/components/particle.vue new file mode 100644 index 000000000..4ea0239b4 --- /dev/null +++ b/src/client/components/particle.vue @@ -0,0 +1,54 @@ + + + + + diff --git a/src/client/components/reaction-picker.vue b/src/client/components/reaction-picker.vue index 3a17a522c..99b27ad9c 100644 --- a/src/client/components/reaction-picker.vue +++ b/src/client/components/reaction-picker.vue @@ -2,7 +2,7 @@
- +
diff --git a/src/client/directives/index.ts b/src/client/directives/index.ts index 2e05b5202..64d33c0ff 100644 --- a/src/client/directives/index.ts +++ b/src/client/directives/index.ts @@ -3,8 +3,10 @@ import Vue from 'vue'; import userPreview from './user-preview'; import autocomplete from './autocomplete'; import size from './size'; +import particle from './particle'; Vue.directive('autocomplete', autocomplete); Vue.directive('userPreview', userPreview); Vue.directive('user-preview', userPreview); Vue.directive('size', size); +Vue.directive('particle', particle); diff --git a/src/client/directives/particle.ts b/src/client/directives/particle.ts new file mode 100644 index 000000000..41509b4ed --- /dev/null +++ b/src/client/directives/particle.ts @@ -0,0 +1,22 @@ +import Particle from '../components/particle.vue'; + +export default { + bind(el, binding, vn) { + 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); + }); + } +};