4 * Copyright 2012, Digital Fusion
5 * Licensed under the MIT license.
6 * http://teamdf.com/jquery-plugins/license/
9 * @desc A small plugin that checks whether elements are within
10 * the user visible viewport of a web browser.
11 * only accounts for vertical position, not horizontal.
13 $.fn.visible = function(partial){
17 viewTop = $w.scrollTop(),
18 viewBottom = viewTop + $w.height(),
19 _top = $t.offset().top,
20 _bottom = _top + $t.height(),
21 compareTop = partial === true ? _bottom : _top,
22 compareBottom = partial === true ? _top : _bottom;
24 return ((compareBottom <= viewBottom) && (compareTop >= viewTop));