Advertisement
lemansky

Untitled

Mar 21st, 2024
557
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.80 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6.     <title>Document</title>
  7.     <style>
  8.         .box{
  9.             background:firebrick;
  10.             width:200px;
  11.             height:200px;
  12.             border-radius:50%;
  13.         }
  14.         body{
  15.             background: gold;
  16.         }
  17.     </style>
  18. </head>
  19. <body>
  20.     <div class="box"></div>
  21.     <script>
  22.         let w = 100, h = 100;
  23.  
  24.         let animate = () => {
  25.             let box = document.querySelector('.box');
  26.             setTimeout(() => {
  27.                 box.style.width = parseFloat(window.getComputedStyle(box).width) - 1 + 'px';
  28.                 box.style.height = parseFloat(window.getComputedStyle(box).height) - 1 + 'px';
  29.                 requestAnimationFrame(animate);
  30.             }, 1000/24);
  31.            
  32.         }
  33.         document.addEventListener('click', (e) => {
  34.             animate();
  35.         });
  36.     </script>
  37. </body>
  38. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement