JSFiddle - React, Tailwind, and code Playground

by mikapon

HTML

<div class="test"></div>

CSS

.test {
  position: absolute;
  background-color: red;
  width: 50px;
  height: 50px;
  top: 0;
  left: 0;
  transition: all 1;
}

.test.on {
  left: 200px;
}

JavaScript

const el = document.querySelector('.test')
el.addEventListener("transitionend", event => {
  console.log('end')
}, true)
el.classList.toggle('on')