From 152247bfda62f96e7d3c1be9609692f4cedb5629 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 31 Mar 2023 16:41:27 +0900 Subject: refactor: remove autobind-decorator dep --- packages/frontend/src/directives/user-preview.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'packages/frontend/src/directives') diff --git a/packages/frontend/src/directives/user-preview.ts b/packages/frontend/src/directives/user-preview.ts index 2f5936de3d..ae12f2670a 100644 --- a/packages/frontend/src/directives/user-preview.ts +++ b/packages/frontend/src/directives/user-preview.ts @@ -1,5 +1,4 @@ import { defineAsyncComponent, Directive, ref } from 'vue'; -import autobind from 'autobind-decorator'; import { popup } from '@/os'; export class UserPreview { @@ -15,9 +14,16 @@ export class UserPreview { this.user = user; this.attach(); + + this.show = this.show.bind(this); + this.close = this.close.bind(this); + this.onMouseover = this.onMouseover.bind(this); + this.onMouseleave = this.onMouseleave.bind(this); + this.onClick = this.onClick.bind(this); + this.attach = this.attach.bind(this); + this.detach = this.detach.bind(this); } - @autobind private show() { if (!document.body.contains(this.el)) return; if (this.promise) return; @@ -53,7 +59,6 @@ export class UserPreview { }, 1000); } - @autobind private close() { if (this.promise) { window.clearInterval(this.checkTimer); @@ -62,34 +67,29 @@ export class UserPreview { } } - @autobind private onMouseover() { window.clearTimeout(this.showTimer); window.clearTimeout(this.hideTimer); this.showTimer = window.setTimeout(this.show, 500); } - @autobind private onMouseleave() { window.clearTimeout(this.showTimer); window.clearTimeout(this.hideTimer); this.hideTimer = window.setTimeout(this.close, 500); } - @autobind private onClick() { window.clearTimeout(this.showTimer); this.close(); } - @autobind public attach() { this.el.addEventListener('mouseover', this.onMouseover); this.el.addEventListener('mouseleave', this.onMouseleave); this.el.addEventListener('click', this.onClick); } - @autobind public detach() { this.el.removeEventListener('mouseover', this.onMouseover); this.el.removeEventListener('mouseleave', this.onMouseleave); -- cgit v1.2.3-freya