Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- <style>
- .box{
- background:firebrick;
- width:200px;
- height:200px;
- border-radius:50%;
- }
- body{
- background: gold;
- }
- </style>
- </head>
- <body>
- <div class="box"></div>
- <script>
- let w = 100, h = 100;
- let animate = () => {
- let box = document.querySelector('.box');
- setTimeout(() => {
- box.style.width = parseFloat(window.getComputedStyle(box).width) - 1 + 'px';
- box.style.height = parseFloat(window.getComputedStyle(box).height) - 1 + 'px';
- requestAnimationFrame(animate);
- }, 1000/24);
- }
- document.addEventListener('click', (e) => {
- animate();
- });
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement