Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="34 - Movimiento Caja" />
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
<div id="caja"></div> 
</body>
</html>
 
(function() {
  var velocidad = 10,
    mueveCaja = function(pasos) {
      var el = document.getElementById("caja"),
        izq = el.offsetLeft; 
      if ((pasos > 0 && izq > 399) || (pasos < 0 && izq < 51)) {
        clearTimeout(timer); 
        timer = setInterval(function() {
          mueveCaja(pasos * -1);  
        }, velocidad);
      }
      el.style.left = izq + pasos + "px"; 
    };
  var timer = setInterval(function () {
    mueveCaja(3);
  }, velocidad);
}());
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
aitormedran0pro
0viewers