Технологии

Как двигать блок по квадрату? - вопрос №4759040

const block = document.querySelector(".block2");
let position = 0; let position2 = 0;
const mover = () => { if (position < 450) { position += 15; block.style.top = `${position}px`; setTimeout(() => { mover(); }, 50) } else if (position >= 450 && position2 < 450) { position2 += 15; block.style.left = `${position2}px`; setTimeout(() => { mover(); }, 50); } else if (position2 >= 450) { position -= 15; block.style.top = `${position}px`; setTimeout(() => { mover(); }, 50) } } mover();

май 15, 2022 г.

  • Всего ответов: 0