Skip to content

Commit dcb7484

Browse files
committed
Improve tooltip
1 parent dc0b09f commit dcb7484

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

app.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,24 +93,25 @@ function showTooltip(e, tooltip) {
9393
// better for smaller displays
9494
tooltipElement.style.maxWidth = window.innerWidth * 2 / 3 + "px";
9595
tooltipElement.style.left = e.pageX - tooltipElement.getBoundingClientRect().width * e.pageX / window.innerWidth + "px";
96+
tooltipElement.style.right = '';
9697
} else {
97-
tooltipElement.style.maxWidth = window.innerWidth / 2 + "px";
98+
tooltipElement.style.maxWidth = window.innerWidth / 2 - 40 + "px";
9899
if (e.pageX + 20 < window.innerWidth - tooltipElement.getBoundingClientRect().width) {
99-
tooltipElement.style.left = e.pageX + 20 + "px";
100+
tooltipElement.style.left = e.pageX + 10 + "px";
100101
tooltipElement.style.right = '';
101102
} else {
102103
tooltipElement.style.left = '';
103-
tooltipElement.style.right = window.innerWidth - e.pageX + 20 + "px";
104+
tooltipElement.style.right = window.innerWidth - e.pageX + 10 + "px";
104105
}
105106
}
106107
if (e.pageY + 20 < window.innerHeight - tooltipElement.getBoundingClientRect().height) {
107-
tooltipElement.style.top = e.pageY + 20 + "px";
108+
tooltipElement.style.top = e.pageY + 10 + "px";
108109
tooltipElement.style.bottom = '';
109110
} else {
110111
tooltipElement.style.top = '';
111-
tooltipElement.style.bottom = window.innerHeight - e.pageY + 20 + "px";
112+
tooltipElement.style.bottom = window.innerHeight - e.pageY + 10 + "px";
112113
}
113-
tooltipElement.style.opacity = 1;
114+
tooltipElement.style.opacity = 0.95;
114115
}
115116

116117
function registerTooptip(element, tooltip) {

styles.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ td {
158158
transition: background-color 0.3s;
159159
}
160160

161-
td:hover {
161+
td[data-code]:hover {
162162
outline: 2px solid #004080;
163163
}
164164

@@ -251,7 +251,7 @@ footer {
251251
color: #7fb6ff;
252252
}
253253

254-
td:hover {
254+
td[data-code]:hover {
255255
outline: 2px solid #96c7ff;
256256
}
257257

0 commit comments

Comments
 (0)