Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

Lay Theme Forum

  1. Home
  2. Feedback
  3. Ability to hide or recolor a navigation bAr after a certain amount of scroll way

Ability to hide or recolor a navigation bAr after a certain amount of scroll way

Scheduled Pinned Locked Moved Feedback
5 Posts 2 Posters 144 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    thomasmaier
    wrote on last edited by
    #1

    This is possible via a script snippet, but this could easily be a setting in the Customizer, right? Set a navigation bar's opacity and background-color for X pixels of scroll height (e.g. 800px, which is a common page fold height).

    Example: Have a full-page first image in your page with the navigation items sitting there with an invisible navigation bar and then let the navigation bar appear when you scroll down below the first image.

    Bonus: Add this feature to the Site Title and e.g. let it get two different size values, so they can change due to scrolling. Or have the option to add a different logo for having scrolled, so you can have a higher or a flatter version of the logo.

    1 Reply Last reply
    0
    • arminunruhA Offline
      arminunruhA Offline
      arminunruh
      Global Moderator
      wrote on last edited by
      #2

      mmh

      did u get it to work using javascript?
      if so can u post it here?

      yea i think its a great idea, but im not sure many people would use it
      i try to not add too many options if not many ppl will use it cause it will just add to the complexity

      T 1 Reply Last reply
      0
      • arminunruhA arminunruh

        mmh

        did u get it to work using javascript?
        if so can u post it here?

        yea i think its a great idea, but im not sure many people would use it
        i try to not add too many options if not many ppl will use it cause it will just add to the complexity

        T Offline
        T Offline
        thomasmaier
        wrote on last edited by
        #3

        @arminunruh

        Hi Armin, I can only talk for myself but I basically need/use this feature in 75% of all the website I make (and I make a lot). It's just so common that you want to have a special first viewport/row or e.g. use the intro feature where a solid navigation bar doesn't look as great - but at the same time you absolutely need it later for scrolling down so the logo wouldn't constantly overlap text. And I hear this all the time, that this should be a feature for Lay Theme from others that use it frequently (like the 'burger menu on desktop' thing ;-) ).

        Here is my code:

        <script>
        function changeCss () {
          var bodyElement = document.querySelector("body");
          var logoElement = document.querySelector(".sitetitle");
          this.scrollY > 350 ? logoElement.style.opacity = 1 : logoElement.style.opacity = 0;
        }
        function changeCss2 () {
          var bodyElement = document.querySelector(".home");
          var logoElement = document.querySelector(".navbar");
          this.scrollY > 350 ? logoElement.style.opacity = 1 : logoElement.style.opacity = 0;
        }
        
        window.addEventListener("scroll", changeCss , false);
        window.addEventListener("scroll", changeCss2 , false);
            
        </script>
        

        It's really simple - it just adds or removes opacity based on scroll way. I have also another one that adds or removes a css class, which gives you a more convenient way to change the style – but I have some issues with it so I can't use it all the time and my JS knowledge is limited.

        1 Reply Last reply
        1
        • arminunruhA Offline
          arminunruhA Offline
          arminunruh
          Global Moderator
          wrote on last edited by
          #4

          mmh yea man u're right

          i should code this!

          T 1 Reply Last reply
          1
          • arminunruhA arminunruh

            mmh yea man u're right

            i should code this!

            T Offline
            T Offline
            thomasmaier
            wrote on last edited by
            #5

            @arminunruh Awesome! Could be great to have settings like transparency, height, color and animation for the navbar.

            1 Reply Last reply
            1
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            I also code custom websites or custom Lay features.
            šŸ’æ Email me here: šŸ’æ
            info@laytheme.com

            Before you post:
            1. When using a WordPress Cache plugin, disable it or clear your cache.
            2. Update Lay Theme and all Lay Theme Addons
            3. Disable all Plugins
            4. Go to Lay Options → Custom CSS & HTML, click "Turn Off All Custom Code", click "Save Changes"

            This often solves issues you might run into

            When you post:
            1. Post a link to where the problem is
            2. Does the problem happen on Chrome, Firefox, Safari or iPhone or Android?
            3. If the problem is difficult to explain, post screenshots / link to a video to explain it
            Online Users
            S
            sebagaga
            Forgot your key, lost your files, need a previous Lay Theme or Addon version? Go to www.laykeymanager.com
            laytheme.com
            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Recent
            • Tags
            • Popular
            • Users
            • Search