-1

I have this jquery code to scroll to an element when another is clicked

$("#element1").click(function() {
        $('html, body').animate({ scrollTop: $("#element2").offset().top }, 1000);
});

Now i need to implement an easeInOutCirc easing on this movement, using the Jquery Easing Plugin http://gsgd.co.uk/sandbox/jquery/easing/

Never seem to get it right, please help

  • So you followed the documentation? Does it not work at all, or is there some other issue. What exactly does "get it right" mean? – adeneo Oct 20 '16 at 19:08
  • Yes I followed the documentation but there no scroll. Here's what I tried: https://jsfiddle.net/a316xhxL/ – user1434010 Oct 20 '16 at 23:13

2 Answers2

1
  $(".scroll-top").on("click", function(e){

      e.preventDefault();

       $("html, body").animate({scrollTop:"0"},900,"easeInSine");
  });
Rubel Hossain
  • 2,503
  • 2
  • 22
  • 23
0

Like it said in the documentation, you have to do :

$("#element1").click(function(e) {
  $('html, body').animate({
    scrollTop: $("#element2").offset().top
  },
  {
    duration: 1000,
    easing: easeInOutCirc
  });
});
w3spi
  • 4,380
  • 9
  • 47
  • 80