animate executing immediately (jQuery v3.3.1)

animate executing immediately (jQuery v3.3.1)

Hi,

I’m writing a site using jQuery 3.3.1. All the animations that I include are running immediately.

For instance:

  1. $('#l_B').css({left: '10px'});
  2. $('#l_B').animate({
  3.                 left: 200
  4. }, {
  5.                 duration: 2000,
  6.                 step: function ( now, fx ) {
  7.                                 console.log('1 >> ' + fx.elem.id + " " + fx.prop + ": " + now);
  8.                 }
  9. });

The element l_B move immediately, in just one step.

 

Going through the animate source (file effects,js), I found that the property “animation.startTime“ sometimes has a Date reference, and sometimes is a number.

When “animation.startTime“is a Date object, the variable “remaining“ is set with NaN instead of a real number:


  1. remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),


I hack the source to correct this adding this line:


  1. if (animation.startTime.getTime != null) animation.startTime = animation.startTime.getTime();


After that, the animations started to work.