Smooth scrolling on pages other than home

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

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #14406
    Mark Scott
    Customer

      Hi Wes

      I’m in the process of converting my Ally site to SquareOne.

      I love the smooth scrolling on the home page. Is it possible to use it on other pages?

      Specifically, I want to use it to scroll to the footer (where my contact form will be) from the menu. It works beautifully on the home page, but just jumps on other pages.

      I’ve used a plugin before, but I’m concerned it will interfere with the smooth scrolling on the home page.

      Any suggestions?

      (Sorry, I can’t link to the SquareOne site. I’m working on it in InstantWP on my laptop.)

      #14418
      Wes
      Moderator

        Yes this is possible. We would have to make a small modification by moving the javascript code in the front-page.php to the functions file so it can work globally, but it an definitely be done.

        #14430
        Mark Scott
        Customer

          Would I need to pay for that?

          It’s only a nice-to-have.

          #14431
          Wes
          Moderator

            No you won’t need to pay, it’s pretty easy. Just let me know whenever you’re ready and I can help you get it setup here.

            #14455
            Mark Scott
            Customer

              Thanks, Wes.

              I’ve made all the other customisations, so I’m ready.

              #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
                }
                #14472
                Mark Scott
                Customer

                  Many thanks, Wes.

                  It works perfectly.

                  #14473
                  Wes
                  Moderator

                    You’re Welcome!

                  Viewing 8 posts - 1 through 8 (of 8 total)
                  • The topic ‘Smooth scrolling on pages other than home’ is closed to new replies.