• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Javscript snippet for Parallax Pro needs tinkering, but unsure how to implement

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Javscript snippet for Parallax Pro needs tinkering, but unsure how to implement

This topic is: resolved

Tagged: css, javascript

  • This topic has 4 replies, 2 voices, and was last updated 11 years, 7 months ago by rfmeier.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • January 3, 2015 at 11:37 pm #135974
    Jason Weber
    Member

    Hey all. I have a javascript snippet that Tonya (tonya_lunarwp) gave me that works wonderfully on my website (Parallax Pro child theme).

    The idea is to have the primary navigation hidden upon page load, and then appear after the user scrolls 150 pixels:

    <script type="text/javascript">
    (function($) {
    $(document).ready(function () {
    var primaryNav = $('body.home').find('nav.nav-primary');
    primaryNav.hide();
    $(window).scroll(function(){
    if ($(this).scrollTop() > 150)
    {
    primaryNav.fadeIn();
    }
    else
    {
    primaryNav.fadeOut();
    }
    });
    });
    })(jQuery);
    </script>

    The problem is that on screen resolutions lower than 688 pixels in width, the menus is hidden, sure, but it never shows up after scrolling; it remains hidden.

    So after trolling around Stack Exchange, I came up with the following idea:

    if (window.screen.availWidth > 687) {

    Should dictate that the javascript loads on screen resolutions 688 pixels or greater.

    But when I put this snippet in Tonya's javascript, the javascript snippet still loads on smaller devices.

    Does anybody know how I can get browsers to ignore this javascript snippet if their device is at a resolution of 687 pixels or less?

    Any guidance would be greatly appreciated!

    Thanks!


    Webby’s WebPrezence
    National Center For Due Process

    https://nationalcdp.org/
    January 4, 2015 at 12:01 pm #136040
    rfmeier
    Member

    Jason,

    You can go off the following. The first if-statement checks the window size on initial load. The second listens for a window resize event;

    // check initial window size
    if( window.innerWidth > 687 ) {
    
    	// hide or show the menu based on the window's initial size
    
    }
    
    // listen for browser resize
    $( window ).on( 'resize', function() {
    	
    	if( window.innerWidth > 687 ) {
    		// hide or show the menu based on window size after resize
    	}
    
    });

    Ryan Meier – Twitter

    January 4, 2015 at 12:10 pm #136041
    rfmeier
    Member

    Jason,

    Here is the full script. I wasn't able to test it, but I you can test it and alter as needed.

    https://gist.github.com/rfmeier/c421a5bf60ec886a38a1


    Ryan Meier – Twitter

    January 4, 2015 at 1:16 pm #136044
    Jason Weber
    Member

    Wow, RF, you're a javascript / jquery genius!

    Nobody on Stack Exchange could help me. I had looked at different windows screen objects and tried to test them (not doing it properly, as you did), but I had never heard of innerWidth.

    But this is precisely the effect I wanted for my nonprofit's multisite -- works exactly how I wanted it to work on different screen resolutions.

    Thank you very much for taking the time to read my question, and then throw that snippet on github.

    Really do appreciate it, RF!

    Thanks again!


    Webby’s WebPrezence
    National Center For Due Process

    January 4, 2015 at 3:26 pm #136060
    rfmeier
    Member

    Jason,

    You are welcome! Good luck.


    Ryan Meier – Twitter

  • Author
    Posts
Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble