console
let reqId = null
function move (distance = 2) {
let box = document.querySelector('.white')
let left = box.style.left || 0
let bottom = box.style.bottom || 0
box.style.left = parseInt(left) + distance + 'px'
box.style.bottom = parseInt(bottom) + distance + 'px'
}
function loop () {
move()
reqId = window.requestAnimationFrame(loop)
if (document.querySelector('.white').offsetLeft >= 250) {
window.cancelAnimationFrame(reqId)
}
}
loop()
<div class="container">
<div class="white"></div>
</div>
.container {
width: 300px;
height: 300px;
background: #000;
position: relative;
}
.white {
width: 50px;
height: 50px;
background: #fff;
position: absolute;
left: 0;
bottom: 0;
}