2014年12月11日木曜日

画面内に.invisible要素が入ったら、.visibleにリネーム

全然検証してないけど、画面内に入ったら何かするってので、使えないだろうか
 var resizeTimer = false;
 $(window).resize('load', function() {
  if (resizeTimer !== false) { clearTimeout(resizeTimer); }
  resizeTimer = setTimeout(function() {
   winHeight = $(window).height();
  }, 20);
 });
 
 $(window).scroll(function(){
  winScrollTop = $(window).scrollTop();
        $('.invisible').each(function() {
         var itemTtop = $(this).offset().top;
            
            if( winScrollTop + winHeight > itemTtop ) {
                $(this).removeClass('invisible');
                $(this).addClass('visibled');
            }
        });
    });

0 件のコメント:

コメントを投稿