This commit is contained in:
syuilo 2020-07-24 16:30:55 +09:00
parent 0007f4915e
commit f9e350b041
4 changed files with 24 additions and 12 deletions

View File

@ -1,4 +1,4 @@
import Vue from 'vue';
import { App } from 'vue';
import userPreview from './user-preview';
import autocomplete from './autocomplete';
@ -6,9 +6,11 @@ import size from './size';
import particle from './particle';
import tooltip from './tooltip';
Vue.directive('autocomplete', autocomplete);
Vue.directive('userPreview', userPreview);
Vue.directive('user-preview', userPreview);
Vue.directive('size', size);
Vue.directive('particle', particle);
Vue.directive('tooltip', tooltip);
export default function(app: App) {
//app.directive('autocomplete', autocomplete);
//app.directive('userPreview', userPreview);
//app.directive('user-preview', userPreview);
app.directive('size', size);
//app.directive('particle', particle);
//app.directive('tooltip', tooltip);
}

View File

@ -1,5 +1,9 @@
import { Directive } from 'vue';
//const observers = new Map<Element, ResizeObserver>();
export default {
inserted(el, binding, vn) {
mounted(el, binding, vn) {
const query = binding.value;
/*
@ -52,7 +56,9 @@ export default {
calc();
vn.context.$on('hook:activated', calc);
// Vue3では使えなくなった
// 無くても大丈夫か...
//vn.context.$on('hook:activated', calc);
const ro = new ResizeObserver((entries, observer) => {
calc();
@ -60,10 +66,12 @@ export default {
ro.observe(el);
// TODO: 新たにプロパティを作るのをやめMapを使う
// ただメモリ的には↓の方が省メモリかもしれないので検討中
el._ro_ = ro;
},
unbind(el, binding, vn) {
unmounted(el, binding, vn) {
el._ro_.unobserve(el);
}
};
} as Directive;

View File

@ -15,6 +15,7 @@ import Root from './root.vue';
import FontAwesomeIcon from './components/fa.vue';
import Stream from './scripts/stream';
import widgets from './widgets';
import directives from './directives';
import { version, langs, getLocale, apiUrl } from './config';
import { store } from './store';
import { router } from './router';
@ -170,8 +171,8 @@ app.component('fa', FontAwesomeIcon);
//#endregion
widgets(app);
directives(app);
//require('./directives');
//require('./components');
document.body.innerHTML = '<div id="app"></div>';

View File

@ -22,6 +22,7 @@ export default defineComponent({
},
props: {
// TODO: propvueobserve
stream: {
},