JSFiddle - React, Tailwind, and code Playground

by andypaxo

HTML

<div id='area'>
    <img
        id='ball'
        src='http://cdn4.iconfinder.com/data/icons/CV_icons_by_miffo/128/interests.png'/>
</div>

CSS

#area { width:100px; height:100px; border:1px solid #aaa; }
#ball { position:absolute; width:16px; height:16px }

JavaScript

var ball = document.getElementById('ball');
var start = Date.now();
var animate = function() {
    var t = Date.now() - start;
    ball.style.left = 42+30*Math.cos(t*.005) + 'px';
    ball.style.top = 42+30*Math.sin(t*.005) + 'px';
    window.requestAnimationFrame(animate);
};
animate();