make top-content component and frame-content component

This commit is contained in:
Shin'ya Ueoka 2017-10-15 09:02:09 +09:00
parent 042aa94936
commit 4c9d0433a6
13 changed files with 102 additions and 76 deletions

View file

@ -0,0 +1,36 @@
import './hint.css';
export default class Hint {
constructor(target, tag) {
if (!(document.body instanceof HTMLElement)) {
throw new TypeError('target is not an HTMLElement');
}
this.target = target;
let doc = target.ownerDocument;
let { top, left } = target.getBoundingClientRect();
let { scrollX, scrollY } = window;
this.element = doc.createElement('span');
this.element.className = 'vimvixen-hint';
this.element.textContent = tag;
this.element.style.left = left + scrollX + 'px';
this.element.style.top = top + scrollY + 'px';
this.show();
doc.body.append(this.element);
}
show() {
this.element.style.display = 'inline';
}
hide() {
this.element.style.display = 'none';
}
remove() {
this.element.remove();
}
}