Advertisement
Guest User

divi animation

a guest
Jun 25th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script type="application/javascript">
  2. (function($) {
  3. $(document).ready(function() {
  4.  
  5. var $animation_elements = $('.et-waypoint'),
  6. $window = $(window);
  7.  
  8. function check_if_in_view() {
  9. var window_height = $window.height(),
  10. window_top_position = $window.scrollTop(),
  11. window_bottom_position = (window_top_position + window_height);
  12.  
  13. $animation_elements.each(function() {
  14. var $element = $(this),
  15. element_height = $element.outerHeight(),
  16. element_top_position = $element.offset().top,
  17. element_bottom_position = (element_top_position + element_height);
  18. //check to see if this element is within viewport
  19. if ((element_bottom_position >= window_top_position) && (element_top_position <= window_bottom_position)) {
  20.     if($('.et_animated').length === 0){
  21.  
  22. $element.addClass('et_animated');
  23. }
  24. } else {
  25. $element.removeClass('et_animated');
  26. }
  27. });
  28. }
  29.  
  30. $window.on('scroll resize', check_if_in_view);
  31.  
  32. });
  33. })(jQuery)
  34. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement