112

When trying to show a div element with jQuery, i got this error:

[23:50:35.971] TypeError: p.easing[this.easing] is not a function @ file:///D:/html5%20puzzle/jquery.js:2

The relevant function is this:

function showWithAnimation(){                  
  console.log('animation called');
  $('#popup').show();
  $("#popup").css({"top": "30%", "left": "30%"})
             .animate({top:(($(window).height()/2)-($('#popup')
             .outerHeight()/2))-70}, 1000, 'easeOutBounce')
             .show();
}

The function is responsible of showing the div with a bounce animation, however, the div is shown but without bounce effect.

EDIT:

I am including jQuery and jQueryUI libraries from a CDN like this (In order):

<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'></script>
<script src='http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js'>
</script>
Malloc
  • 15,434
  • 34
  • 105
  • 192

12 Answers12

158

You need to include jQueryUI for the extended easing options.

I think there may be an option to only include the easing in the download, or at least just the base library plus easing.

I Hate Lazy
  • 47,415
  • 13
  • 86
  • 77
21

For those who have a custom jQuery UI build (bower for ex.), add the effects core located in ..\jquery-ui\ui\effect.js.

Tim Vermaelen
  • 6,869
  • 1
  • 25
  • 39
  • 3
    I only had to use a single effect, so I was able to make due with just `import "jquery-ui/ui/effects/effect-slide"`. Thanks for the tip, Tim! – aried3r May 07 '19 at 11:16
15

Including this worked for me.

Please include the line mentioned below in the section.

<script src='http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js'>

Manju
  • 151
  • 1
  • 4
12

Jquery easing plugin renamed their effect function names from version 1.2 on. If you have some javascript depending on easing and it is not calling the right effect name it will throw this error.

ericopter
  • 121
  • 2
5

I got this error today whilst trying to initiate a slide effect on a div. Thanks to the answer from 'I Hate Lazy' above (which I've upvoted), I went looking for a custom jQuery UI script, and you can in fact build your own file directly on the jQuery ui website http://jqueryui.com/download/. All you have to do is mark the effect(s) that you're looking for and then download.

I was looking for the slide effect. So I first unchecked all the checkboxes, then clicked on the 'slide effect' checkbox and the page automatically then checks those other components necessary to make the slide effect work. Very simple.

easeOutBounce is an easing effect, for which you'll need to check the 'Effects Core' checkbox.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
luke_mclachlan
  • 1,035
  • 1
  • 15
  • 35
4

If you're using Bootstrap it's also possible that Bootstrap's jQuery, if included below your jQuery script tag, is overwriting your jQuery script tag with another version. Including jQuery's own CDN and deleting the jQuery script tag that Bootstrap provides was the only thing that worked for me.

Matthew Hinea
  • 1,872
  • 19
  • 31
3

Importing jquery.easing cdn worked for me.

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.4.1/jquery.easing.min.js"></script>

You can add this bottom of the webpage.

Farid Chowdhury
  • 2,766
  • 1
  • 26
  • 21
1

For anyone going through this error and you've tried updating versions and making sure effects core is present etc and still scratching your head. Check the documentation for animate() and other syntax.

All I did was write "Linear" instead of "linear" and got the [this.easing] is not a function

$("#main").animate({ scrollLeft: '187px'}, 'slow', 'Linear'); //bad

$("#main").animate({ scrollLeft: '187px'}, 'slow', 'linear'); //good

tree
  • 391
  • 2
  • 16
1

I discovered a very strange thing, but important to know: When you installed jQuery ui (1.12.1) a lot of easings work, e.g.:

jQuery('#my-elm').animate({marginLeft:500},1000,'linear');
jQuery('#my-elm').animate({marginLeft:500},1000,'easeOutBounce');

works, but the default:

jQuery('#my-elm').animate({marginLeft:500},1000,'swipe');

generates very many errors

Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
opajaap
  • 11
  • 1
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/29798450) – SimpleCoder Sep 11 '21 at 20:20
0

I have found the problem: Don't use CDN (this is causing the problem!), instead save the jquery file locally on your server and then the problem is away.

A J
  • 3,970
  • 14
  • 38
  • 53
0

use the latest one for bootstrap 4 and above, this won't affect your UI

salman ifrahim
  • 371
  • 3
  • 8
0

In my case it was an error in the js code. Once i fixed it the error went away. The error was something like this.

$("#id").removeClass("class-1","class-2","class-3");

Apparently this isn't how to remove multiple classes at a time.

  • But this is not related in any way with the question (which, btw, got a highly upvoted and accepted answers. So this is not rhetorical: we know for sure that your answer is off topic) – chrslg Dec 11 '22 at 10:06