-
Notifications
You must be signed in to change notification settings - Fork 0
/
theySeeMeScrolling.js
16 lines (15 loc) · 1011 Bytes
/
theySeeMeScrolling.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
(function($){
$.fn.inView = function(partial,hidden){
var $t = $(this).eq(0),
t = $t.get(0),
$w = $(window),
viewTop = $(this).scrollParent().offset().top,
viewBottom = viewTop + $(this).scrollParent().height();
_top = $t.offset().top,
_bottom = _top + $t.height(),
compareTop = partial === true ? _bottom : _top,
compareBottom = partial === true ? _top : _bottom,
clientSize = hidden === true ? t.offsetWidth * t.offsetHeight : true;
return !!clientSize && ((compareBottom <= viewBottom) && (compareTop >= viewTop));
};
})(jQuery);