Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. <html>
  2. <style>
  3. #dv{
  4.  
  5. border:1px solid red;
  6. background-color:#344;
  7. height:80px;
  8. position:absolute;
  9. }
  10. #dv2{
  11.  
  12. border:1px solid black;
  13. background-color:#f00;
  14. height:80px;
  15. position:absolute;
  16.  
  17. }
  18.  
  19.  
  20.  
  21.  
  22. </style>
  23. <body>
  24. <div id = "dv"></div>
  25. <div id = "dv2"></div>
  26. <script>
  27. var valor = 0;
  28. var valor2 = 180;
  29. var dv= document.getElementById("dv");
  30. var div2 = document.getElementById("dv2");
  31.  
  32. var largura = dv.style.width = 80;
  33. var lateral = div2.style.left = 180;
  34. var largura2 = div2.style.width = 80;
  35. var lateral2 = div2.style.top = 300;
  36.  
  37. function moverDiv(){
  38. valor += 5;
  39. dv.style.left = valor+"px";
  40.  
  41.  
  42. if(valor+largura > lateral){
  43. div2.style.backgroundColor = "blue";
  44.  
  45.  
  46. }
  47. }
  48. dv.addEventListener("touchmove",moverDiv);
  49.  
  50.  
  51.  
  52.  
  53.  
  54. </script>
  55. </body>
  56. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement