<style>
* {
padding: 0;
margin: 0;
}
#box {
width: 100px;
height: 100px;
background: skyblue;
position: fixed;
left: 0;
top: 0;
}
</style>
<body>
<div id="box"></div>
</body>
<script>
var oBox = document.querySelector('#box');
var direction = 1000;
var speed = 30;
var timer = setInterval(function () {
var left = oBox.offsetLeft;
speed--;
speed = speed <= 1 ? 1 : speed;
left += speed;
if (left >= direction) {
clearInterval(timer);
left = direction;
}
oBox.style.left = left + 'px';
}, 10)
</script>