Advertisement
Guest User

Untitled

a guest
Nov 16th, 2019
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. <!DOCTYPE HTML>
  2. <html>
  3.  
  4. <head>
  5. <style>
  6. #myDIV {
  7. height: 300px;
  8. width: 600px;
  9. overflow: auto;
  10. background: green;
  11. }
  12.  
  13. #content {
  14. margin:500px;
  15. height: 800px;
  16. width: 2000px;
  17. position: relative;
  18. cursor: pointer;
  19. }
  20. </style>
  21. </head>
  22.  
  23. <body>
  24. <div id="myDIV">
  25. <img style="width: 30px; height: 30px;" id="content" src="image.jpg">
  26. </div>
  27. <button id="move">Move</button>
  28.  
  29. <script>
  30. move.onclick = function() {
  31. let start = Date.now();
  32.  
  33. let timer = setInterval(function() {
  34. let timePassed = Date.now() - start;
  35.  
  36. content.style.right = timePassed / -5 + 'px';
  37.  
  38. if (timePassed > 2500) clearInterval(timer);
  39.  
  40. }, 20);
  41. }
  42. </script>
  43.  
  44. <script>
  45. function myFunction() {
  46. var elmnt = document.getElementById("content");
  47. elmnt.scrollIntoView();
  48. }
  49.  
  50. setInterval(() => {
  51. myFunction();
  52. }, 100);
  53. setInterval(() => {
  54. myFunction();
  55. }, 200);
  56. </script>
  57.  
  58. </body>
  59.  
  60. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement