JSFiddle - React, Tailwind, and code Playground

HTML

<div id="mouche"></div>

CSS

#mouche {position:absolute;width:20px;height:20px;top:100px;background:#000;-moz-border-radius:10px;-webkit-border-radius:10px;border-radius:10px;}

JavaScript

var mouche = document.getElementById("mouche"),
	x = 0, y, animation;

animation = setInterval(function(){
	x++;
	y = Math.cos(Math.PI * x / 5) * 10 + 100;
	mouche.style.top = y + 'px';
	mouche.style.left = x + 'px';
	x == 120 && clearInterval(animation);
}, 40);