Reply To: Smooth scrolling on pages other than home

Homepage Community Forums SquareOne Theme Support Smooth scrolling on pages other than home Reply To: Smooth scrolling on pages other than home

#14471
Wes
Moderator

    If you take a look at your front-page.php file near the bottom you’ll see the javascript code that adds the scroll. You’ll need to copy and remove it from this page, and then add it to your functions file so that it will work globally –

    // Adds javascript for scroll
    add_action( 'genesis_after_footer', 'scroll_javascript' );
    function scroll_javascript() { ?>
    	<!-- SMOOTH SCROLL -->
    	<script src="http://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
    }