Advertisement
1xptolevitico69

window.requestAnimationFrame

Jan 4th, 2022
1,523
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.78 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.  
  4. <head>
  5.   <title>window.requestAnimationFrame</title>
  6.   <meta charset="UTF-8">
  7.   <meta name="viewport" content="width=device-width">
  8.   <style>
  9.  
  10.     .clone {
  11.       position: absolute;
  12.       top: 10px;
  13.       left: 10px;
  14.       text-decoration: none;
  15.       background-color: snow;
  16.       width: 150px;
  17.       text-align: center;
  18.       color: red;
  19.       font-family: arial black;
  20.       padding: 5px 20px;
  21.     }
  22.  
  23.     body {
  24.       background-color: red;
  25.       margin: 0;
  26.       overflow: hidden;
  27.     }
  28.  
  29.     #p {
  30.       font-size: 35px;
  31.       font-family: courier;
  32.       text-indent: 100px;
  33.       text-align: justify;
  34.       padding: 20px;
  35.       color: red;
  36.       font-style: italic;
  37.     }
  38.  
  39.     div {
  40.       width: 50%;
  41.       position: absolute;
  42.       left: 25%;
  43.       top: 0;
  44.       background-color: snow;
  45.       height: 100vh;
  46.       overflow-Y: scroll;
  47.     }
  48.   </style>
  49. </head>
  50.  
  51. <body>
  52.   <div>
  53.     <h1 id='p'></h1>
  54.   </div>
  55.  
  56.   <a class='clone' title="Subscribe and hit the notification bell for more updates. It's free." href='https://www.youtube.com/channel/UCqLpDK0eOsG1eEeF9jOUZkw'>SUBSCRIBE</a>
  57.  
  58.  
  59.  
  60.  
  61.  
  62.   <script>
  63.     post = ['One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin. He lay on his armour-like back, and if he lifted his head a little he could see his brown belly, slightly domed and divided by arches into stiff sections. '];
  64.     i = 0;
  65.     b = 0;
  66.     bam = post[i];
  67.     setTimeout(function() {
  68.       (start = () => {
  69.         x = requestAnimationFrame(start);
  70.         foo = bam[b];
  71.         p.innerHTML += foo;
  72.         b++;
  73.         if (b == bam.length) {
  74.           cancelAnimationFrame(x);
  75.         }
  76.       })();
  77.     }, 2000);
  78.   </script>
  79. </body>
  80. </htm>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement