Skip to main content

Hawaii Department of Commerce and Consumer Affairs, Office of Consumer Protection, Landlord Tenant Information Center

Citation
Hawaii Department of Commerce and Consumer Affairs, Office of Consumer Protection, Landlord Tenant Information Center
Jurisdiction
Hawaii (state)
Source
Official source

Related Parts of This Source

Full Text

1,358 chars
const scrollTop = window.pageYOffset || document.documentElement.scrollTop;

// Check if mega menu is visible
const isMegaMenuOpen =
megaMenu && getComputedStyle(megaMenu).display !== "none";

if (isMegaMenuOpen) {
header.classList.add('show');
header.classList.remove('hide');
lastScrollTop = scrollTop;
return;
}

if (scrollTop > 120 && scrollTop > lastScrollTop) {
// scrolling down
header.classList.add('hide');
header.classList.remove('show');
} else if (scrollTop < lastScrollTop) {
// scrolling up
header.classList.add('show');
header.classList.remove('hide');
}

lastScrollTop = Math.max(scrollTop, 0);
});

// Scroll to the element with the hash id on load and on hashchange.
// If target is behind "Show More" or inside a collapsed FAQ, click Show More and/or open the FAQ first.

function scrollToHashElement() {
const hash = window.location.hash;
if (!hash || hash.length <= 1) return;

const id = decodeURIComponent(hash.substring(1));
const el = document.getElementById(id);
if (!el) return;

function doScroll() {
const target = document.getElementById(id);
if (!target) return;
requestAnimationFrame(function() {
const rect = target.getBoundingClientRect();
const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
const top = Math.max(0, rect.top + scrollTop - 16);
window.scrollTo({
top: top,
behavior: 'smooth'
});
});
}