Skip to content

Instantly share code, notes, and snippets.

View soysantana's full-sized avatar
💛
Studying a new language

Arturo Santana soysantana

💛
Studying a new language
  • Dominican Republic
  • 09:27 (UTC -04:00)
View GitHub Profile
const element = document.getElementById("animateMe");
let positionX = 0;
let direction = 1;
function animate() {
positionX += 5 * direction;
element.style.transform = `translateX(${positionX}px)`;
// Cambiar dirección cuando llegue al borde derecho o izquierdo del contenedor
if (positionX >= window.innerWidth - element.clientWidth || positionX <= 0) {