JSFiddle - React, Tailwind, and code Playground

HTML

<div id="preloader_div">
  <div class='moving'></div>
  <div id="preloader_img">&nbsp;</div>
</div>
<div class="text"> 
  <!-- Website Content -->
  <p> Nulla sodales ac mi quis egestas. Etiam rhoncus sollicitudin nisl, vitae malesuada nulla dictum vitae. Vivamus facilisis erat nec pulvinar pellentesque. Sed pellentesque pharetra porta. Mauris ac malesuada mauris. Aliquam laoreet tempus eros pretium porta. Morbi nec nisi consectetur, vehicula quam nec, euismod urna. Vivamus eget tincidunt mauris, vitae facilisis ex. Nulla sed gravida eros. Quisque tristique feugiat mi, vel porta lectus sodales et. Nunc efficitur tincidunt lacinia. Curabitur urna dui, feugiat quis nibh et, rhoncus accumsan neque. </p>
</div>

CSS

.text {
	border: 2px solid #a1a1a1;
	padding: 10px 40px;
	background: #dddddd;
	width: 300px;
	border-radius: 25px;
	position: absolute;
	left: 50%;
	top: 50%;
	margin: -155px 0 0 -190px;
}

div.moving {
  background: transparent;
  border: 5px solid black;
  border-radius: 100%;
  height: 50px;
  position: fixed;
  width: 50px;
  z-index: 999;
  box-shadow: 0 0 0 9999px black;
}

JavaScript

$(document).ready(function(){
    animateDiv();
});

function makeNewPosition(){
    
    // Get viewport dimensions (remove the dimension of the div)
    var h = $(window).height() - 50;
    var w = $(window).width() - 50;
    
    var nh = Math.floor(Math.random() * h);
    var nw = Math.floor(Math.random() * w);
    
    return [nh,nw];    
    
}

function animateDiv(){
    var newq = makeNewPosition();
    var oldq = $('.moving').offset();
    var speed = calcSpeed([oldq.top, oldq.left], newq);
    
    $('.moving').animate({ top: newq[0], left: newq[1] }, speed, function(){
      animateDiv();        
    });
    
};

function calcSpeed(prev, next) {
    
    var x = Math.abs(prev[1] - next[1]);
    var y = Math.abs(prev[0] - next[0]);
    
    var greatest = x > y ? x : y;
    
    var speedModifier = 0.1;

    var speed = Math.ceil(greatest/speedModifier);

    return speed;

}