Add fixed hint bar when header is not visible

This commit is contained in:
天クマ 2026-04-23 17:12:29 -03:00
commit b54133ddd2
3 changed files with 55 additions and 11 deletions

View file

@ -618,6 +618,16 @@ div.hs.selected {
opacity: 0.6;
}
#fixedHint {
position: fixed;
top: 0;
left: 0;
background-color: black;
z-index: 10;
padding: .2em;
outline: thin solid var(--theme-color);
}
#sound {
filter: invert();
}

View file

@ -1,15 +1,49 @@
/* This script provides functionality similar to FL Studio's hint panel. */
const body = document.querySelector('body');
const elements = document.querySelectorAll('[data-tip]');
const hint = document.querySelector("#headerSubtitle");
const hintPanelDefaultText = hint.innerHTML;
let fixedHint;
let currentObserver;
elements.forEach(el => {
el.addEventListener('mouseenter', function() {
hint.innerHTML = `${this.dataset.tip}`;
el.addEventListener('mouseenter', function() {
cleanup();
if (currentObserver) {
currentObserver.disconnect();
}
currentObserver = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (!entry.isIntersecting) {
fixedHint = document.createElement('p');
fixedHint.id = "fixedHint";
fixedHint.innerHTML = el.dataset.tip;
fixedHint.setAttribute('aria-hidden', 'true');
body.appendChild(fixedHint);
} else {
hint.innerHTML = el.dataset.tip;
}
})
});
el.addEventListener('mouseleave', function() {
hint.innerHTML = hintPanelDefaultText;
});
hint.innerHTML = el.dataset.tip;
currentObserver.observe(hint);
});
el.addEventListener('mouseleave', function() {
cleanup();
});
})
function cleanup() {
hint.innerHTML = hintPanelDefaultText;
hint.classList.remove('fixed');
if (fixedHint) {
fixedHint.remove();
}
if (currentObserver) {
currentObserver.disconnect();
currentObserver = null;
}
}