JSFiddle - React, Tailwind, and code Playground

HTML

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

CSS

@keyframes diagonalslide {

    from {
      left: 0;
    }

    to {
      left: 100px;
    }

}
@-moz-keyframes diagonalslide {

    from {
      left: 0;
    }

    to {
      left: 100px;
    }

}
@-o-keyframes diagonalslide {

    from {
      left: 0;
    }

    to {
      left: 100px;
    }

}
@-webkit-keyframes diagonalslide {

    from {
      left: 0;
    }

    to {
      left: 100px;
    }

}

#box {
    width: 20px;
    height: 20px;
    background-color: #FF0000;
    border: 1px solid #333333;
    position: absolute;
    top: 0px;
    left: 0px;
    
    animation-name: diagonalslide;
    animation-duration: 1s;
    animation-iteration-count: 10;
    animation-direction: alternate;
    
    -moz-animation-name: diagonalslide;
    -moz-animation-duration: 1s;
    -moz-animation-iteration-count: 10;
    -moz-animation-direction: alternate;
    
    -o-animation-name: diagonalslide;
    -o-animation-duration: 1s;
    -o-animation-iteration-count: 10;
    -o-animation-direction: alternate;
    
    -webkit-animation-name: diagonalslide;
    -webkit-animation-duration: 1s;
    -webkit-animation-iteration-count: 10;
    -webkit-animation-direction: alternate;
}
#output {
    margin-top: 30px;
}

JavaScript

var box = document.getElementById('box');
var d = new Date();

box.addEventListener('animationstart', function () {
        d = new Date();
    }, false);
box.addEventListener('animationiteration', function () {
        document.getElementById('output').innerHTML += ((new Date() - d) / 1000)+" second<br />";
        d = new Date();
    }, false);