Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(function(){
  2.     funcoes.init();
  3.  
  4.     $(window).resize(function() {
  5.         if($(window).width() >= 960){
  6.             setTimeout(function(){
  7.                 funcoes.recalcular();
  8.             }, 500)
  9.         } else {
  10.             $('.slide-program').css('width', '100%');
  11.             $('.card-serie').css('width', '100%');
  12.         }
  13.     });
  14.  
  15.     $(window).scroll(function () {
  16.         $('.set-anchor').each(function(i, el){
  17.             if ($(this).isInViewport()) {
  18.               $('.menu-item').eq(i).addClass('is-sec-active')
  19.               $('.menu-item').eq(i).siblings().removeClass('is-sec-active')
  20.             }
  21.         })
  22.     })
  23. });
  24.  
  25. $.fn.isInViewport = function () {
  26.     let elementTop = $(this).offset().top;
  27.     let elementBottom = elementTop + $(this).outerHeight();
  28.  
  29.     let viewportTop = $(window).scrollTop();
  30.     let viewportBottom = viewportTop + $(window).height() / 3.5;
  31.  
  32.     return elementBottom > viewportTop && elementTop < viewportBottom;
  33. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement