PageSourceSearch

https://www.winterhavendaily.com/wp-content/plugins/Winter%20Haven…/js/jquery.viewportchecker.js?ver=7.1.2

js winterhavendaily.com collected 2026-10-03 00:36:00 UTC 5,005 bytes, 127 lines download raw bytes

1/*
2    Version 1.7.3
3    The MIT License (MIT)
4
5    Copyright (c) 2014 Dirk Groenen
6    
7    Authors:
8        Dirk Groenen <[email protected]>
9        Jono    
10        Michael Brüggemann
11        Suraj Air <[email protected]>
12
13    Permission is hereby granted, free of charge, to any person obtaining a copy of
14    this software and associated documentation files (the "Software"), to deal in
15    the Software without restriction, including without limitation the rights to
16    use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
17    the Software, and to permit persons to whom the Software is furnished to do so,
18    subject to the following conditions:
19
20    The above copyright notice and this permission notice shall be included in all
21    copies or substantial portions of the Software.
22
23
24*/
25
26(function($){
27    $.fn.viewportChecker = function(useroptions){
28        // Define options and extend with user
29        var options = {
30            classToAdd: 'visible',
31            classToRemove : 'invisible',
32            offset: 100,
33            repeat: false,
34            callbackFunction: function(elem, action){},
35            scrollHorizontal: false
36        };
37        $.extend(options, useroptions);
38
39        // Cache the given element and height of the browser
40        var $elem = this,
41            windowSize = {height: $(window).height(), width: $(window).width()},
42            scrollElem = ((navigator.userAgent.toLowerCase().indexOf('webkit') != -1) ? 'body' : 'html');
43
44        /*
45         * Main method that checks the elements and adds or removes the class(es)
46         */
47        this.checkElements = function(){
48
49            // Set some vars to check with
50            if(!options.scrollHorizontal){
51                var viewportStart = $(scrollElem).scrollTop(),
52                    viewportEnd = (viewportStart + windowSize.height);
53            }
54            else{
55                var viewportStart = $(scrollElem).scrollLeft(),
56                    viewportEnd = (viewportStart + windowSize.width);
57            }
58
59            // Loop through all given dom elements
60            $elem.each(function(){
61                var $obj = $(this),
62                    objOptions = {},
63                    attrOptions = {};
64
65                //  Get any individual attribution data
66                if ($obj.data('vp-add-class'))
67                    attrOptions.classToAdd = $obj.data('vp-add-class');
68                if ($obj.data('vp-remove-class'))
69                    attrOptions.classToRemove = $obj.data('vp-remove-class');
70                if ($obj.data('vp-offset'))
71                    attrOptions.offset = $obj.data('vp-offset');
72                if ($obj.data('vp-repeat'))
73                    attrOptions.repeat = $obj.data('vp-repeat');
74                if ($obj.data('vp-scrollHorizontal'))
75                    attrOptions.scrollHorizontal = $obj.data('vp-scrollHorizontal');
76
77                // Extend objOptions with data attributes and default options
78                $.extend(objOptions, options);
79                $.extend(objOptions, attrOptions);
80
81                // If class already exists; quit
82                if ($obj.hasClass(objOptions.classToAdd) && !objOptions.repeat){
83                    return;
84                }
85
86                // define the top position of the element and include the offset which makes is appear earlier or later
87                var elemStart = (!objOptions.scrollHorizontal) ? Math.round( $obj.offset().top ) + objOptions.offset : Math.round( $obj.offset().left ) + objOptions.offset,
88                    elemEnd = (!objOptions.scrollHorizontal) ? elemStart + $obj.height() : elemStart + $obj.width();
89
90                // Add class if in viewport
91                if ((elemStart < viewportEnd) && (elemEnd > viewportStart)){
92
93                    // remove class
94                    $obj.removeClass(objOptions.classToRemove);
95
96                    $obj.addClass(objOptions.classToAdd);
97
98                    // Do the callback function. Callback wil send the jQuery object as parameter
99                    objOptions.callbackFunction($obj, "add");
100
101                // Remove class if not in viewport and repeat is true
102                } else if ($obj.hasClass(objOptions.classToAdd) && (objOptions.repeat)){
103                    $obj.removeClass(objOptions.classToAdd);
104
105                    // Do the callback function.
106                    objOptions.callbackFunction($obj, "remove");
107                }
108            });
109
110        };
111
112        // Run checkelements on load and scroll
113        $(window).bind("load scroll touchmove", this.checkElements);
114
115        // On resize change the height var
116        $(window).resize(function(e){
117            windowSize = {height: $(window).height(), width: $(window).width()},
118            $elem.checkElements();
119        });
120
121        // trigger inital check if elements already visible
122        this.checkElements();
123
124        // Default jquery plugin behaviour
125        return this;
126    };
127})(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.