smooth scroll to anchor function ??

asked Nov 26 in Joomla Templates by teddydebehr (120 points)
edited Nov 26 by teddydebehr
I´m looking for a function that will be run in a template toaster template smooth scroll to anchor !

Please help.

Thank´s from Germany

2 Answers

answered Nov 27 by lisa-west (28,840 points)

As I am unable to clearly understand your query, please elaborate it little more so that  I can clearly understand and guide you accordingly.

answered Nov 27 by bp-web (220 points)
I did use the below script that i found on https://css-tricks.com/snippets/jquery/smooth-scrolling/:

I pasted the script just before the </head> tag in the index.php file of the template and created an anchor and anchor link with JCE. This worked fine for me.

<!-- SMOOTH SCROLL -->
<script src="https://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 -->
commented Nov 28 by teddydebehr (120 points)
Thank´s a lot it works.
Have a nice day from Germany
Anyone interested in localization of TemplateToaster v7 in exchange of a Pro License Contact Us
...