PageSourceSearch

https://tyda.se/static/js/jquery.viewport.js?v=74956321f8cb1b23a9641113d13c504a

js tyda.se collected 2026-10-02 06:13:55 UTC 2,839 bytes, 75 lines download raw bytes

1/*
2 * Viewport - jQuery selectors for finding elements in viewport
3 *
4 * Copyright (c) 2008-2009 Mika Tuupola
5 *
6 * Licensed under the MIT license:
7 *   http://www.opensource.org/licenses/mit-license.php
8 *
9 * Project home:
10 *  http://www.appelsiini.net/projects/viewport
11 *
12 * CUSTOM HACKS BY NYHETER24GRUPPEN AT LINES:
13 * 23 (added extra height)
14 * 44-51 (added inscreen method)
15 * 69-71 (added caller for inscreen method)
16 *
17 */
18(function($) {
19    
20    $.belowthefold = function(element, settings) {
21        var fold = $(window).height() + $(window).scrollTop();
22        return fold <= $(element).offset().top - settings.threshold;
23    };
24
25    $.abovethetop = function(element, settings) {
26        var top = $(window).scrollTop() + 94; // 94 = height of right-now + menu
27        return top >= $(element).offset().top + $(element).height() - settings.threshold;
28    };
29    
30    $.rightofscreen = function(element, settings) {
31        var fold = $(window).width() + $(window).scrollLeft();
32        return fold <= $(element).offset().left - settings.threshold;
33    };
34    
35    $.leftofscreen = function(element, settings) {
36        var left = $(window).scrollLeft();
37        return left >= $(element).offset().left + $(element).width() - settings.threshold;
38    };
39    
40    $.inviewport = function(element, settings) {
41        return !$.rightofscreen(element, settings) && !$.leftofscreen(element, settings) && !$.belowthefold(element, settings) && !$.abovethetop(element, settings);
42    };
43    
44    $.inscreen=function(element) {
45    	//The heights/widths should be divided by 2 to ensure half the element is visible, but we do not want to affect ad impressions too much at this point so
46    	//initially the value is 4 to allow for more frequent ad reloads
47	    return !$.rightofscreen(element, {threshold: -$(element).width()/2}) && 
48	           !$.leftofscreen(element, {threshold: $(element).width()/2}) && 
49	           !$.belowthefold(element, {threshold: -$(element).height()/2}) && 
50	           !$.abovethetop(element, {threshold: $(element).height()/2});
51    }
52    
53    $.extend($.expr[':'], {
54        "below-the-fold": function(a, i, m) {
55            return $.belowthefold(a, {threshold : 0});
56        },
57        "above-the-top": function(a, i, m) {
58            return $.abovethetop(a, {threshold : 0});
59        },
60        "left-of-screen": function(a, i, m) {
61            return $.leftofscreen(a, {threshold : 0});
62        },
63        "right-of-screen": function(a, i, m) {
64            return $.rightofscreen(a, {threshold : 0});
65        },
66        "in-viewport": function(a, i, m) {
67            return $.inviewport(a, {threshold : 0});
68        },
69        "in-screen": function(a,i,m) {
70	        return $.inscreen(a);
71        }
72    });
73
74    
75})(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.