Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.03 KB | None | 0 0
  1. <html>
  2. <head>
  3. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
  4. <style>
  5. .bubble {
  6.     transform: scale(0);
  7.     width: 500px;
  8.     height: 500px;
  9.     border-radius: 50%;
  10.     background-color: #C00;
  11.     transition: all 1s;
  12. }
  13. .bubble.animate {
  14.     transform: scale(1);
  15. }
  16. </style>
  17. </head>
  18. <body>
  19.  
  20.   <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
  21.   <div class='bubble'></div>
  22.  
  23. <script>
  24. $(document).ready(function() {
  25. $(window).scroll( function(){
  26.  
  27.       /* Check the location of each desired element */
  28.       $('.bubble').each( function(i){
  29.  
  30.         var elemTop = $(this).getBoundingClientRect().top;
  31.         var elemBottom = $(this).getBoundingClientRect().bottom;
  32.         var isVisible = (elemTop >= 0) && (elemBottom <= window.innerHeight);
  33.  
  34.           /* If the object is completely visible in the window, fade it it */
  35.           if(isVisible){
  36.  
  37.               $(this).addClass('animate');
  38.  
  39.           }
  40.  
  41.       });
  42. });
  43.   });
  44. </script>
  45. </body>
  46. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement