This commit is contained in:
MeiMei 2020-02-20 00:38:26 +09:00 committed by GitHub
parent e6c9b1d9bd
commit 3f83beedb7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View file

@ -51,6 +51,7 @@ export default Vue.extend({
target: self ? null : '_blank', target: self ? null : '_blank',
showTimer: null, showTimer: null,
hideTimer: null, hideTimer: null,
checkTimer: null,
preview: null, preview: null,
faExternalLinkSquareAlt faExternalLinkSquareAlt
}; };
@ -78,9 +79,14 @@ export default Vue.extend({
}).$mount(); }).$mount();
document.body.appendChild(this.preview.$el); document.body.appendChild(this.preview.$el);
this.checkTimer = setInterval(() => {
if (!document.body.contains(this.$el)) this.closePreview();
}, 1000);
}, },
closePreview() { closePreview() {
if (this.preview) { if (this.preview) {
clearInterval(this.checkTimer);
this.preview.destroyDom(); this.preview.destroyDom();
this.preview = null; this.preview = null;
} }

View file

@ -8,9 +8,11 @@ export default {
self.tag = null; self.tag = null;
self.showTimer = null; self.showTimer = null;
self.hideTimer = null; self.hideTimer = null;
self.checkTimer = null;
self.close = () => { self.close = () => {
if (self.tag) { if (self.tag) {
clearInterval(self.checkTimer);
self.tag.close(); self.tag.close();
self.tag = null; self.tag = null;
} }
@ -37,6 +39,10 @@ export default {
self.hideTimer = setTimeout(self.close, 500); self.hideTimer = setTimeout(self.close, 500);
}); });
self.checkTimer = setInterval(() => {
if (!document.body.contains(el)) self.close();
}, 1000);
document.body.appendChild(self.tag.$el); document.body.appendChild(self.tag.$el);
}; };
@ -62,6 +68,7 @@ export default {
const self = el._userPreviewDirective_; const self = el._userPreviewDirective_;
clearTimeout(self.showTimer); clearTimeout(self.showTimer);
clearTimeout(self.hideTimer); clearTimeout(self.hideTimer);
clearInterval(self.checkTimer);
self.close(); self.close();
} }
}; };