Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • Saguaros Moderator
    #1072054

    Hi,

    With the back to top button, we add small script so it can animate slowly like that. You can see that script in footer block: root/templates/ja_company/tpls/blocks/footer.php

    For the main menu, it would be more complicated, I recommend you to hire a developer to get it done for you (if you’re not familiar with JS code)

    kimremme Friend
    #1072204

    Thank you,
    I added some js code to the same "back to top" script at root/templates/ja_company/tpls/blocks/footer.php

    <script type="text/javascript">
    (function($) {
      // Back to top
      $('#back-to-top').on('click', function(){
        $("html, body").animate({scrollTop: 0}, 500);
        return false;
      });
        // Add smooth scrolling to all links
      $("a").on('click', function(event) {
    
        // Make sure this.hash has a value before overriding default behavior
        if (this.hash !== "") {
          // Prevent default anchor click behavior
          event.preventDefault();
    
          // Store hash
          var hash = this.hash;
    
          // Using jQuery's animate() method to add smooth page scroll
          // The optional number (800) specifies the number of milliseconds it takes to scroll to the specified area
          $('html, body').animate({
            scrollTop: $(hash).offset().top
          }, 800, function(){
    
            // Add hash (#) to URL when done scrolling (default click behavior)
            window.location.hash = hash;
          });
        } // End if
      });
    })(jQuery);
    &lt;/script&gt;

    This will make every link to anchor on page scroll smooth.

Viewing 2 posts - 1 through 2 (of 2 total)

This topic contains 2 replies, has 2 voices, and was last updated by  kimremme 6 years, 6 months ago.

The topic ‘One page function (anchor with smooth scroll)’ is closed to new replies.