PageSourceSearch

https://visualhealthsolutions.com/library/js/libs/jquery.inview.js

js visualhealthsolutions.com collected 2026-10-07 15:52:29 UTC 2,036 bytes, 60 lines download raw bytes

1/**
2 * author Remy Sharp
3 * url http://remysharp.com/2009/01/26/element-in-view-event-plugin/
4 */
5(function ($) {
6    function getViewportHeight() {
7        var height = window.innerHeight; // Safari, Opera
8        var mode = document.compatMode;
9
10        if ( (mode || !$.support.boxModel) ) { // IE, Gecko
11            height = (mode == 'CSS1Compat') ?
12            document.documentElement.clientHeight : // Standards
13            document.body.clientHeight; // Quirks
14        }
15
16        return height;
17    }
18
19    $(window).scroll(function () {
20        var vpH = getViewportHeight(),
21            scrolltop = (document.documentElement.scrollTop ?
22                document.documentElement.scrollTop :
23                document.body.scrollTop),
24            elems = [];
25        
26        // naughty, but this is how it knows which elements to check for
27        $.each($.cache, function () {
28            if (this.events && this.events.inview) {
29                elems.push(this.handle.elem);
30            }
31        });
32
33        if (elems.length) {
34            $(elems).each(function () {
35                var $el = $(this),
36                    top = $el.offset().top,
37                    height = $el.height(),
38                    inview = $el.data('inview') || false;
39
40                if (scrolltop > (top + height) || scrolltop + vpH < top) {
41                    if (inview) {
42                        $el.data('inview', false);
43                        $el.trigger('inview', [ false ]);                        
44                    }
45                } else if (scrolltop < (top + height)) {
46                    if (!inview) {
47                        $el.data('inview', true);
48                        $el.trigger('inview', [ true ]);
49                    }
50                }
51            });
52        }
53    });
54    
55    // kick the event to pick up any elements already in view.
56    // note however, this only works if the plugin is included after the elements are bound to 'inview'
57    $(function () {
58        $(window).scroll();
59    });
60})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.