fork download
  1.  
  2. var pos = -1;
  3. var img = null;
  4. var endpos = 0;
  5. var windowSize = 0;
  6. var timer = null;
  7.  
  8.  
  9. function updateLocation() {
  10. if(pos>endpos) {
  11. pos-=60;
  12. img.style.left = pos + "px";
  13. }
  14. }
  15.  
  16. function startMoving(ID, end) {
  17. img = document.getElementById(ID);
  18. img.style.position = "absolute";
  19. endpos = end;
  20. pos = windowSize + 200;
  21. timer = setInterval('updateLocation()', 50);
  22. }
  23.  
  24. function stopMoving() {
  25. img.style.left = windowSize + 200 + "px";
  26. clearInterval(timer);
  27. }
  28.  
  29. function init(img1, img2) {
  30. windowSize = window.screen.width;
  31. img1_img = document.getElementById(img1);
  32. img2_img = document.getElementById(img2);
  33. img2_img.style.position = "absolute";
  34. img1_img.style.position = "absolute";
  35. img1_img.style.left = windowSize + img1_img.width + "px";
  36. img2_img.style.left = windowSize + img2_img.width + "px";
  37.  
  38. }
Success #stdin #stdout 0.28s 213120KB
stdin
Standard input is empty
stdout
Standard output is empty