mirror of
https://github.com/vale981/tridactyl
synced 2025-03-06 01:51:40 -05:00
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:
parent
61a01efeab
commit
dcb6620240
2 changed files with 24 additions and 0 deletions
|
@ -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"
|
||||
|
|
|
@ -37,6 +37,11 @@
|
|||
background: #f9f5ff !important;
|
||||
}
|
||||
|
||||
.TridactylInvisible {
|
||||
opacity: 0 !important;
|
||||
pointer-events: none !important;
|
||||
}
|
||||
|
||||
@media print {
|
||||
.TridactylStatusIndicator {
|
||||
display: none !important;
|
||||
|
|
Loading…
Add table
Reference in a new issue