// Wait for the DOM to be ready document.addEventListener("DOMContentLoaded", function () { // Select the box element const box = document.getElementById('box'); // Use GSAP to animate the box gsap.to(box, { x: 300, // Destination X position duration: 2, // Animation duration in seconds ease: "power2.inOut", // Easing function (optional) repeat: -1, // Repeat the animation indefinitely yoyo: true // Reverse the animation on each repeat }); });
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter