Possible Issue with Javascript Scroll Code

Homepage Community Forums SquareOne Theme Support Possible Issue with Javascript Scroll Code

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #14251
    Lloyd
    Customer

      I’m having an issue on a site where the theme is not playing nicely with a plugin. Both use jquery. I’ve contacted the plugin developer and am contacting you as well. Hopefully we can figure out whose code is not properly constructed.

      The code in question is:

      // Adds javascript for scroll
      add_action( 'genesis_after_footer', 'scroll_javascript' );
      function scroll_javascript() { ?>
      	<!-- SMOOTH SCROLL -->
      	<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
      	<script>
      	$(function() {
      	  $('a[href*=#]:not([href=#])').click(function() {
      	    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
      	      var target = $(this.hash);
      	      target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
      	      if (target.length) {
      	        $('html,body').animate({
      	          scrollTop: target.offset().top
      	        }, 1000);
      	        return false;
      	      }
      	    }
      	  });
      	});
      	</script>
      	<!-- End of SMOOTH SCROLL -->
      <?php
      }
      #14252
      Eric
      Customer

        If I were you I’d just remove that block of code. That code is for the little arrow that they have on the demo. Unless you absolutely need it, I’d just remove it from your home.php file as it’s not needed in order for the theme to work. Wes mentioned in another thread that he’ll probably be removing and replacing it in a future update anyways.

        The only reason I’m saying remove it is because you’re trying to use another plugin that also uses jquery. It’s very easy for two jquery sources to conflict in WordPress. I’ve seen it happen on plenty of themes/plugins.


        I create awesome sites for awesome people! Contact me if interested – ericsanchez1585@gmail.com

        #14266
        Lloyd
        Customer

          Yeah, I’ve removed it although I do like the effect. But as you said, removing it doesn’t break the theme.

          #14267
          Lloyd
          Customer

            Also, for curiosity I added this plugin https://wordpress.org/plugins/jquery-smooth-scroll and it worked with no issues in conjunction with the other.

            #14330
            Eric
            Customer

              Cool, I’ll check that out.


              I create awesome sites for awesome people! Contact me if interested – ericsanchez1585@gmail.com

            Viewing 5 posts - 1 through 5 (of 5 total)
            • The topic ‘Possible Issue with Javascript Scroll Code’ is closed to new replies.