0

I want to add an easing style into my smooth scrolling code, but whenever I do it throws a constantly increasing jquery error in the console.

$('#slider-scrollDown').click(function() {
    $('html, body').animate({
        scrollTop: $("#scrollTo-container").offset().top
    }, 2000);
});

This is what I have, and I'm trying to add an easing like this:

$('#slider-scrollDown').click(function() {
    $('html, body').animate({
        scrollTop: $("#scrollTo-container").offset().top
    }, 2000, 'easeInOut');
});

The errors I receive in the console are:

Uncaught TypeError: n.easing[this.easing] is not a function

Which displays once, and then another below it with an increasing number in red, which doesn't stop.

Lee
  • 4,187
  • 6
  • 25
  • 71

2 Answers2

0

It's because easeInOut does not exist... Have a look on this page ;) https://api.jqueryui.com/easings/

R. Foubert
  • 633
  • 4
  • 8
0

Hmm I overlooked something when trying to load easing. I didn't mention that I'm using Wordpress, and I've just discovered that an extra function call is needed to get the jQuery easing functions.

Simply adding wp_enqueue_script ( 'jquery-effects-core' ); to my list of loads solved the issue.

Thanks everyone.

Lee
  • 4,187
  • 6
  • 25
  • 71
  • Alex, why the downvote? Don't be down just because I downvoted your answer, it wasn't helpful! – Lee Jul 14 '16 at 11:03