Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to execute 'animate' on 'Element': Partial keyframes are not supported

I try to add an animation to a div using jquery :

$('#footer').animate({ "width" : "13%" },1000);

it works but an error is displayed in the console like:

"Failed to execute 'animate' on 'Element': Partial keyframes are not supported." enter image description here

when i click on the right link :

enter image description here

but when i use a value in pixel there is no error with :

$('#footer').animate({ "width" : 68 },1000);

is there a solution to use responsive values ?

like image 254
Mimouni Avatar asked Jul 14 '16 14:07

Mimouni


People also ask

How do you add a keyframe animation?

Add or insert frames in the timeline To insert a new frame, select Insert > Timeline > Frame (F5). To create a keyframe, select Insert > Timeline > Keyframe (F6), or right-click (Windows) or Control‑click (Macintosh) the frame where you want to place a keyframe, and select Insert Keyframe from the context menu.

How many keyframes do you need to create an animation?

To create keyframe animations, you need at least two keyframes with different values of the same property. Keyframe animations are formed based on the property change from the start to the end.

What is keyframe offset?

The offset of the keyframe specified as a number between 0.0 and 1.0 inclusive or null . This is equivalent to specifying start and end states in percentages in CSS stylesheets using @keyframes . If this value is null or missing, the keyframe will be evenly spaced between adjacent keyframes.


2 Answers

The problem is the way you call .animate(). You have jQuery added to your codebase but you are using the web platform's animate with the way you have called .animate(). If you want this to work fine with jQuery change from:

var player = this.move_.animate();

to

var player = $(this.move_).animate();

but if you'd like to use the JavaScript animate over jQuery then you can have this

var player = this.move_.animate({transform: [parameters.transformBegin, parameters.transformEnd]});

I have no idea what your parameters are but my example shows you add the multiple key frames as an array for each property you are animating

like image 157
Joseph Rex Avatar answered Nov 15 '22 00:11

Joseph Rex


You fell into a trap. The $ you are using is not jQuery, but it's a console's API, a shortcut for document.querySelector

This means that $('#footer') does not return a jQuery object but a plain DOM element.

This means that .animate is not jQuery's method but the element's method, so you're unknowingly using the Web Animation API, not jQuery.animate.

They have a different API and you get the error.

In short, make sure that jQuery is available on your page and/or use jQuery('#footer').animate(et cetera)

like image 41
fregante Avatar answered Nov 15 '22 00:11

fregante