-
Notifications
You must be signed in to change notification settings - Fork 29
/
Tooltip.js
33 lines (27 loc) · 960 Bytes
/
Tooltip.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
export default class Tooltip {
constructor(container) {
const div = document.createElement('DIV');
div.className = "twipsy right";
const arrow = document.createElement('DIV');
arrow.className = "twipsy-arrow";
div.appendChild(arrow);
const title = document.createElement('DIV');
title.className = "twipsy-inner";
div.appendChild(title);
this._div = div;
this._title = title;
// add to frame div and display coordinates
container.appendChild(div);
}
setVisible(visible) {
this._div.style.display = visible ? 'block' : 'none';
}
showAt(position, message) {
if (position && message) {
this.setVisible(true);
this._title.innerHTML = message;
this._div.style.left = position.x + 10 + "px";
this._div.style.top = (position.y - this._div.clientHeight / 2) + "px";
}
}
}