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. General Discussion
  3. custom code for desktop menu only

custom code for desktop menu only

Scheduled Pinned Locked Moved General Discussion
4 Posts 2 Posters 436 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.
  • R Offline
    R Offline
    robin
    wrote on Oct 16, 2017, 8:04 PM last edited by robin Oct 16, 2017, 4:06 PM
    #1

    Hi,
    I'm hiding the main menu of my website until the user starts scrolling. Here is the jquery:

    jQuery(window).scroll(function() {
        if (jQuery(window).scrollTop() > 120) {
            jQuery("nav.primary").fadeIn();
        }
        else {
            jQuery("nav.primary").fadeOut();
        }
        });
    

    however, I never want to hide the mobile menu. How can I prevent this to happen? I tried to check it these ways because these are changing in my inspector when I go from desktop to mobile layout:

    if (jQuery("body").hasClass( "lightbox-css-on" ))
    if (jQuery('nav.primary').css('max-height') == '566px')

    but this doesn't seem to work. Any help?

    Thanks !

    Robin

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mariusjopen
      Global Moderator
      wrote on Oct 18, 2017, 8:16 AM last edited by
      #2

      Hi @robin

      I would go for this way:

      if ($(window).width() > 767) {
      // YOUR CODE HERE
      }
      

      Also have a look here:
      http://laytheme.com/documentation.html#custom-javascript

      Let me know if you got further.

      Best!

      Marius

      www.mariusjopen.world

      1 Reply Last reply
      0
      • R Offline
        R Offline
        robin
        wrote on Oct 26, 2017, 2:43 PM last edited by
        #3

        Hi,

        thanks! It's almost perfect now. I still have one problematic situation when the user manually resizes the window under 767px wide because then the "Custom CSS for Desktop Version" is still loaded with the "display: none" property that I use on the menu so it is not visible when the page is loaded. I guess I could fix this with more javascript or maybe this should be implemented in the theme directly (loading the right custom css when user resizes the window)?

        Thanks for your time.
        Best,

        Robin

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mariusjopen
          Global Moderator
          wrote on Oct 27, 2017, 10:26 AM last edited by
          #4

          Have a look here:

          <script>
            jQuery(function () {
              if (jQuery(window).width() > 600) {
                // YOUR CODE HERE	
              }
          
              jQuery(window).on('resize', function () {
                if (jQuery(window).width() > 600) {
                   // YOUR CODE HERE	
                }
              });
          
              jQuery(window).on('resize', function () {
                if (jQuery(window).width() <= 600) {
                  // YOUR DISABLING CODE HERE	
                }
              });
            });
          
          </script>
          
          

          Maybe you need to adjust it with this:
          http://laytheme.com/documentation.html#custom-javascript

          But that should cover it.

          Best!

          Marius

          www.mariusjopen.world

          1 Reply Last reply
          0
          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
          dmncnD
          dmncn
          27 minutes ago
          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