<div id="block">click me</div>
#block{
position:absolute;
left: 100px;
top: 50%;
width: 100px;
height: 100px;
margin: -50px 0 0 -50px;
background: #0c8;
line-height: 100px;
text-align: center;
color: #fff;
cursor: pointer;
}
View Compiled
var stats = new Stats();
stats.showPanel( 0 );
document.body.appendChild( stats.dom );
block.addEventListener('click', function(){
stats.begin();
var self = this, startTime = Date.now(),
distance = 500, duration = 5000;
requestAnimationFrame(function step(){
var p = Math.min(1.0, (Date.now() - startTime) / duration);
self.style.transform = 'translateX(' + (distance * p) +'px)';
if(p < 1.0) {
requestAnimationFrame(step);
stats.end();
}
});
});
This Pen doesn't use any external CSS resources.