PageSourceSearch

https://sabrinaferilli.it/wp-content/plugins/vc-social-stream/assets/js/jquery.viewportchecker.js?ver=6.7.1

js sabrinaferilli.it collected 2026-10-02 10:12:43 UTC 5,481 bytes, 131 lines download raw bytes

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