if (menu.length) { $(window).on("scroll", function () { // fix the issue causing the nav never show again. var topDistance = document.documentElement.scrollTop;// menu.offset().top;
// hide only the navigation links on desktop const distanceLimit = 50; if (!nav.is(":visible") && topDistance < distanceLimit) { nav.show(); } elseif (nav.is(":visible") && topDistance >= distanceLimit) { nav.hide(); }
// on tablet, hide the navigation icon as well and show a "scroll to top // icon" instead if (!$("#menu-icon").is(":visible") && topDistance < distanceLimit) { $("#menu-icon-tablet").show(); $("#top-icon-tablet").hide(); } elseif (!$("#menu-icon").is(":visible") && topDistance >= distanceLimit) { $("#menu-icon-tablet").hide(); $("#top-icon-tablet").show(); } }); }