2013-02-23 9 views
1

inview.js 스크립트를 조작 할 수있는 방법을 알고 싶습니다. 해고가 뷰포트의 첫 번째 픽셀에없고 순간적으로 요소가 밖으로 나올 때가 마지막입니다. 예를 들어 50pixels 이전 또는 이후. inview.js의 스크립트 내이 시도가 작동 최고 top = $el.offset().top + 50,을 상쇄 값을 추가하는 것이 었습니다inview.js가 실행 중일 때 조작합니다.

(function ($) { 
function getViewportHeight() { 
    var height = window.innerHeight; // Safari, Opera 
    var mode = document.compatMode; 

    if ((mode || !$.support.boxModel)) { // IE, Gecko 
     height = (mode == 'CSS1Compat') ? 
     document.documentElement.clientHeight : // Standards 
     document.body.clientHeight; // Quirks 
    } 

    return height; 
} 

$(window).scroll(function() { 
    var vpH = getViewportHeight(), 
     scrolltop = (document.documentElement.scrollTop ? 
      document.documentElement.scrollTop : 
      document.body.scrollTop), 
     elems = []; 

    // naughty, but this is how it knows which elements to check for 
    $.each($.cache, function() { 
     if (this.events && this.events.inview) { 
      elems.push(this.handle.elem); 
     } 
    }); 

    if (elems.length) { 
     $(elems).each(function() { 
      var $el = $(this), 
       top = $el.offset().top, 
       height = $el.height(), 
       inview = $el.data('inview') || false; 

      if (scrolltop > (top + height) || scrolltop + vpH < top) { 
       if (inview) { 
        $el.data('inview', false); 
        $el.trigger('inview', [ false ]);       
       } 
      } else if (scrolltop < (top + height)) { 
       if (!inview) { 
        $el.data('inview', true); 
        $el.trigger('inview', [ true ]); 
       } 
      } 
     }); 
    } 
}); 

// kick the event to pick up any elements already in view. 
// note however, this only works if the plugin is included after the elements are bound to 'inview' 
$(function() { 
    $(window).scroll(); 
}); 
})(jQuery); 

모든 크레딧 이동

here입니다! 하지만 어떻게하면 아래쪽의 가치를 바꿀 수 있습니까? 감사 테드

답변

1

나는 당신이 바닥에서 10 %에 원하는 효과를 달성하기과 같이 호출 할 수 있습니다 어떤 http://imakewebthings.com/jquery-waypoints/

사용하는 것이 좋습니다 것 :

$('.flyIn').waypoint(function() { 
    $(this).removeClass('hidden'); 
    $(this).addClass('animated fadeInUp'); 
    }, { offset: '90%' }); 
관련 문제