Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML>
- <html>
- <head>
- <style>
- #myDIV {
- height: 300px;
- width: 600px;
- overflow: auto;
- background: green;
- }
- #content {
- margin:500px;
- height: 800px;
- width: 2000px;
- position: relative;
- cursor: pointer;
- }
- </style>
- </head>
- <body>
- <div id="myDIV">
- <img style="width: 30px; height: 30px;" id="content" src="image.jpg">
- </div>
- <button id="move">Move</button>
- <script>
- move.onclick = function() {
- let start = Date.now();
- let timer = setInterval(function() {
- let timePassed = Date.now() - start;
- content.style.right = timePassed / -5 + 'px';
- if (timePassed > 2500) clearInterval(timer);
- }, 20);
- }
- </script>
- <script>
- function myFunction() {
- var elmnt = document.getElementById("content");
- elmnt.scrollIntoView();
- }
- setInterval(() => {
- myFunction();
- }, 100);
- setInterval(() => {
- myFunction();
- }, 200);
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement