• So, I am not that new to using jquery, but I haven’t used wordpress for that long. I am working on a site and a couple of the scripts I am running seem to either (a) take a second to initiate or (b) initiate too soon, before they should, and then there must be user interaction for them to correct themselves. I’m not using enqueue for them right now, which I know you’re supposed to, but I don’t think it should be causing this problem. Anyone have an idea to why?

    For an example check out the drop down header here: nextworld.kbddev.com. It isn’t supposed to drop down until a certain point in the page, but it shows up anyway when the page loads, then disappears upon scroll.

    Another example, on the team page, the photos are scripted to go black/white, and they do, but not after they first show up as color.

    [Moderator note: Duplicate thread removed]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Moderator t-p

    (@t-p)

    Thread Starter thesublimeobject

    (@thesublimeobject)

    Thank you, I didn’t know about the script debug. Unfortunately, that didn’t help, and I know there aren’t any errors in the script already. The scripts themselves work, they just aren’t initiating correctly. Any other suggestions?

    Thread Starter thesublimeobject

    (@thesublimeobject)

    Hey guys, seriously thanks for trying to help, but does anyone have maybe a particular possible solution to my problem? I’m not trying to be sarcastic, but I have tried some of these things and I am aware that the codex exists. I’ve done a lot of searching.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Can you demonstrate the JavaScript and its correct behavior on JSfiddle? Then try switching themes to explore whether the issue is specific to your theme.

    Thread Starter thesublimeobject

    (@thesublimeobject)

    Sorry, I should have included the code. Silly me. I can do a Fiddle, but since it won’t really work very well due to the animation. What is supposed to happen is a secondary header is supposed to pop down when the scroll hits > 542. That IS happening. Exactly how I want it to. The problem is on the window load, the bar itself is showing up until the user scrolls, then it disappears, and works correctly. If you scroll back up, it works well, still. Only on the initial load is the drop-down bar appearing incorrectly (it shouldn’t appear at all.

    Here is the code:

    <div id="follownav">
    	<div class="follownavwrap">
    		<nav>
    			<div id="nav-logo-2"><a href="<?php bloginfo('url'); ?>"><img src="<?php bloginfo( 'stylesheet_directory' ); ?>/images/footer_logo.png" width="225" id="navv-logo"></a></div>
    			<ul class="jsnav">
        			<li><a href="/companies">Companies</a></li>
        			<li><a href="/team">Team</a></li>
    			    <li><a href="/global">Global</a></li>
    			    <li><a href="/about">About</a></li>
    			    <li><a href="/contact">Contact</a></li>
    			</ul>
    		</nav>
    	</div>
    </div>
    
    #follownav {
    	height: 70px;
    	width: 100%;
    	background: #000;
    	position: fixed;
    	top:0;
    	z-index: 9999999;
    	padding: 0;
    	margin: 0;
    }
    
    .hide {
    	display: none;
    }
    
    .show {
    	display: block;
    }
    
    #follownav ul {
    	list-style: none;
    }
    
    #follownav ul li {
    	display: inline-block;
    }
    
    #follownav ul li a {
    	display: inline-block;
    	text-decoration: none;
    	color: #fff;
    	font-family: 'proxima-nova', sans-serif;
    	text-transform: uppercase;
    }
    
    #nav-logo-2 {
    	width: 200px;
    	margin: 0;
    	padding: 0;
    	float: left;
    
    }
    
    .jsnav {
    	width: 600px;
    	margin: 0;
    	padding: 0;
    }
    
    $(window).scroll(function(){
          if($(window).scrollTop() > 542){
              $("#follownav").slideDown("fast");
              $('#follownav').removeClass('hide').addClass('show');
    
          }
        });
        $(window).scroll(function(){
          if($(window).scrollTop() < 542){
              $("#follownav").slideUp("fast");
          }
        });

    Link to site:nextworld.kbddev.com

    I should mention this is a custom theme, so I can’t switch themes.

    Moderator t-p

    (@t-p)

    this is a custom theme, so I can’t switch themes.

    perhaps you want to contact the theme’s vendor go get guidance as to how to use what you are trying to do.

    Thread Starter thesublimeobject

    (@thesublimeobject)

    @t-p, I built the theme myself..

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Javascripts not initiating correctly’ is closed to new replies.