Move an element right over a duration with requestAnimationFrame
Write a function that animates an HTML element to move towards the right by a specified distance over a given duration. The function should utilize the requestAnimationFrame method to ensure smooth animation. See MDN’s requestAnimationFrame() reference for how the callback timestamp works.
Example:
Input:
elementID: ‘hello’distance: 400duration: 1000Expected Output:
The element with the ID ‘hello’ should gradually move 400 pixels to the right over a duration of 1000 milliseconds.