content.{ts,css}: Make modeindicator disappear on hover

This fixes https://github.com/cmcaine/tridactyl/issues/565
I chose to append a TridactylInvisible class instead of setting the
modeindicator setting to false or manually removing the element from the
DOM because this seemed more robust (e.g. when "modeindicator" is set to
true, you expect it to stay set to true and for the element to exist
within the DOM).
This commit is contained in:
glacambre 2018-05-31 21:47:06 +02:00
parent 61a01efeab
commit dcb6620240
No known key found for this signature in database
GPG key ID: B9625DB1767553AC
2 changed files with 24 additions and 0 deletions

View file

@ -100,6 +100,25 @@ config.getAsync("modeindicator").then(mode => {
: ""
statusIndicator.className =
"cleanslate TridactylStatusIndicator " + privateMode
// This listener makes the modeindicator disappear when the mouse goes over it
statusIndicator.addEventListener("mouseenter", ev => {
let target = ev.target as any
let rect = target.getBoundingClientRect()
target.classList.add("TridactylInvisible")
let onMouseOut = ev => {
// If the mouse event happened out of the mode indicator boundaries
if (
ev.clientX < rect.x ||
ev.clientX > rect.x + rect.with ||
ev.clientY < rect.y ||
ev.clientY > rect.y + rect.height
) {
target.classList.remove("TridactylInvisible")
window.removeEventListener("mousemouve", onMouseOut)
}
}
window.addEventListener("mousemove", onMouseOut)
})
try {
// On quick loading pages, the document is already loaded
statusIndicator.textContent = state.mode || "normal"

View file

@ -37,6 +37,11 @@
background: #f9f5ff !important;
}
.TridactylInvisible {
opacity: 0 !important;
pointer-events: none !important;
}
@media print {
.TridactylStatusIndicator {
display: none !important;