Hello everyone. I’m currently doing a task related to animation using animate() in DOM. I’ve got a div in html and my task it to animate it to the left or right when button is pressed.
I created a div with styles
I got id of that div using getElementById() and placed it to variable
I added eventListener to the variable and need to animate it to the right or left
code is below:
The first argument is the keyframe object (or array of objects). It is for the properties and value you want to animate. The second argument is the options, which is either a numeric value or an object with the “configurations” properties like duration, direction and so on.
There aren’t any keyframes there. Animation is changing one or several values (position, colour, etc) over time. You go from one to another. The first argument needs to be an array of keyframes: