Sticky header - Forum | JoomShaper
Solved Templates

Sticky header

Asked by Kugata 10 months ago Last activity 10 months ago

How to make the header sticky in the Helix Ultimate to reappear when scrolling down only?

Accepted answer

Marked as the solution
Paul Frankowski Senior Staff

Oh, indeed, but as I said before, this kind JS/CSS customization is on your hands only.

4 more replies

Paul Frankowski Senior Staff
10 months ago · edited

If you have template from other seller/developer, you have to ask them , or use Custom CSS to make it possible.


Other header behavior customization, request using Custom CSS/JS and are on your hands only.

Kugata Asked this
10 months ago · edited

Paul, you didn't understand my question. I want the header sticky to appear only when scrolling down and disappear when scrolling up.
Template Helix Ultimate. Probably it is need to add some extra code to the file main.js?

Kugata Asked this

The solution is

  1. To add in the main.js after string 60:

         window.onscroll = function() {
             scrollFunction();
         };
    
         function scrollFunction() {
             const header = document.getElementById("sp-header");
             // Check if scrolling up/down
             if (window.scrollY < window.scroll.previousY) {
                 header.classList.remove("header-hidden"); // Show header when scrolling up
             } else {
                 header.classList.add("header-hidden"); // Hide header when scrolling down
             }
             window.scroll.previousY = window.scrollY; // Store current scroll position
         }
    
     2. To add some CSS to the template:
     #sp-header{
     transition: all .5s;
     &.header-hidden {
             top: -80px;
           }
        }
Log in to reply.