JSFiddle - React, Tailwind, and code Playground

by c_vilander

HTML

<div id="box"></div>

CSS

#box {
    position: relative;
    top: 10px;
    left: 10px;
    width: 100px;
    height: 150px;
    background: #393939;
    -webkit-animation: move 3s ease-in-out;
    animation: move 3s ease-in-out;
    -webkit-animation-play-state: paused;
    animation-play-state: paused;
}
@-webkit-keyframes move {
    100% {
        left: 300px;
    }
}
@keyframes move {
    100% {
        left: 300px;
    }
}

JavaScript

(function () {
    "use strict";

    var box = document.getElementById('box');

    box.onclick = function () {

        if (box.style.animationPlayState === "running") {
            box.style.animationPlayState = "paused";

        } else {
            box.style.animationPlayState = "running";
        }

    };
})();