0

I have this piece of code which does a smooth scroll to a tag with an ID.

$('html, body').animate({
    scrollTop: $($this.attr("href")).offset().top - (menuWrapper.height() + 25)
}, 750);

It works but when it reacts the location and you try to scroll up or down it fights you until 750 milliseconds is reached.

How can I prevent this from happening.

André Ferraz
  • 1,511
  • 11
  • 29
  • What is your desired behaviour? User scrolling to be disabled until animation finishes? If so, this will do the trick: https://stackoverflow.com/a/24322725/4108884, just bind the event on animation start and unbind it on animation end. – Samuil Petrov Jun 23 '17 at 08:00
  • I want the scrolling of the animation to be disabled once it reaches its destination even if the animation timer has not reached the 750 milliseconds. – André Ferraz Jun 23 '17 at 09:41

0 Answers0