JSFiddle - React, Tailwind, and code Playground

by Darby Rathbone

HTML

<div>0</div>

CSS

html, body * {
    margin:0px;
    padding:0px;
    width:100%;
    height:100%;
    overflow:hidden;
}
div {
   outline:solid red 1px;
    font-size:3em;
    width:auto;
    height:auto;
    position:absolute;
}3

JavaScript

var m = [0, 0],
    a;
addEventListener('mousemove', function (e) {
    m[0] = e.x;
    m[1] = e.y;
    
});
var spinloop = function () {
    a = document.elementFromPoint( m[0], m[1]);
    if (a instanceof HTMLDivElement) {
        a.style.top = (Math.random() * (window.innerHeight - parseInt(getComputedStyle(a).height))) + "px";
        a.style.left = (Math.random() * (window.innerWidth - parseInt(getComputedStyle(a).width))) + "px";
        a.childNodes[0].textContent = parseInt(a.childNodes[0].textContent)+1;
    }
    setTimeout(function () {
        spinloop();
    });
};
setTimeout(spinloop);