console
var start = null;
var num=0;
var element = document.getElementById('SomeElementYouWantToAnimate');
function step(timestamp) {
if (!start) start = timestamp;
var progress = (timestamp - start)%2000;
element.style.left = Math.min(progress*(Math.sin(num+=0.01)) / 10, 200) + 'px';
window.requestAnimationFrame(step);
}
window.requestAnimationFrame(step);
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Document</title>
</head>
<body>
<div id="SomeElementYouWantToAnimate"></div>
<div class="test"></div>
</body>
</html>
#SomeElementYouWantToAnimate {
width: 20px;
height: 20px;
background: #555;
position: relative;
}
.test{
display:inline-block;
width: 50px;
height: 50px;
background-color:#888;
background-clip:padding-box;
border-radius:50%;
border:5px solid;
padding: 15px;
}
.test:hover {
font-size: 40px;
}