Skip to content

Failed to execute ‘animate’ on ‘element’: parameter 1 is not of type ‘object’

this.animate = 
 function(name,color){ = name; color;




As a minimum you need an animation object and a duration for the animation Element.animate(). And then I think you got some of your code upside down.

const animate = function(element, animationObj, colorStr) {
  element.animate(animationObj, {
    duration: 2000
  }); = colorStr;

let testElm = document.getElementById("test");

animate(testElm, {
  transform: 'translateY(120px)'
}, 'red');
<div id="test">test<div>