]> arthur.barton.de Git - netdata.git/blob - web/lib/visible.js
made all charts update the legend on chart update; added easy-pie-chart (not active...
[netdata.git] / web / lib / visible.js
1 (function($){
2
3         /**
4          * Copyright 2012, Digital Fusion
5          * Licensed under the MIT license.
6          * http://teamdf.com/jquery-plugins/license/
7          *
8          * @author Sam Sehnert
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.
12          */
13         $.fn.visible = function(partial){
14
15             var $t                              = $(this),
16                 $w                              = $(window),
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;
23
24                 return ((compareBottom <= viewBottom) && (compareTop >= viewTop));
25     };
26 })(jQuery);