PageSourceSearch

https://numato.com/wp-content/themes/manual/js/appear.js?ver=4.9.33

js numato.com collected 2026-10-02 05:08:50 UTC 4,331 bytes, 128 lines download raw bytes

vendor: 4,320 bytes, lines 1-127
1/*
2 * jQuery.appear
3 * https://github.com/bas2k/jquery.appear/
4 * http://code.google.com/p/jquery-appear/
5 * http://bas2k.ru/
6 *
7 * Copyright (c) 2009 Michael Hixson
8 * Copyright (c) 2012-2014 Alexander Brovikov
9 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
10 */
11
12(function($) {
13    $.fn.appear = function(fn, options) {
14        var settings = $.extend({
15            //arbitrary data to pass to fn
16            data: undefined,
17            //call fn only on the first appear?
18            one: true,
19            // X & Y accuracy
20            accX: 0,
21            accY: 0
22        }, options);
23
24        return this.each(function() {
25            var t = $(this);
26            //whether the element is currently visible
27            t.appeared = false;
28            if (!fn) {
29                //trigger the custom event
30                t.trigger('appear', settings.data);
31                return;
32            }
33            var w = $(window);
34            //fires the appear event when appropriate
35            var check = function() {
36                //is the element hidden?
37                if (!t.is(':visible')) {
38                    //it became hidden
39                    t.appeared = false;
40                    return;
41                }
42                //is the element inside the visible window?
43                var a = w.scrollLeft();
44                var b = w.scrollTop();
45                var o = t.offset();
46                var x = o.left;
47                var y = o.top;
48                var ax = settings.accX;
49                var ay = settings.accY;
50                var th = t.height();
51                var wh = w.height();
52                var tw = t.width();
53                var ww = w.width();
54
55                if (y + th + ay >= b &&
56                    y <= b + wh + ay &&
57                    x + tw + ax >= a &&
58                    x <= a + ww + ax) {
59                    //trigger the custom event
60                    if (!t.appeared) t.trigger('appear', settings.data);
61                } else {
62                    //it scrolled out of view
63                    t.appeared = false;
64                }
65            };
66
67
68            //create a modified fn with some additional logic
69            var modifiedFn = function() {
70                //mark the element as visible
71                t.appeared = true;
72                //is this supposed to happen only once?
73                if (settings.one) {
74                    //remove the check
75                    w.unbind('scroll', check);
76                    var i = $.inArray(check, $.fn.appear.checks);
77                    if (i >= 0) $.fn.appear.checks.splice(i, 1);
78                }
79
80                //trigger the original fn
81                fn.apply(this, arguments);
82            };
83
84
85            //bind the modified fn to the element
86            if (settings.one) t.one('appear', settings.data, modifiedFn);
87            else t.bind('appear', settings.data, modifiedFn);
88            //check whenever the window scrolls
89            w.scroll(check);
90
91            //check whenever the dom changes
92            $.fn.appear.checks.push(check);
93            //check now
94            (check)();
95        });
96    };
97
98    //keep a queue of appearance checks
99    $.extend($.fn.appear, {
100        checks: [],
101        timeout: null,
102        //process the queue
103        checkAll: function() {
104            var length = $.fn.appear.checks.length;
105            if (length > 0) while (length--) ($.fn.appear.checks[length])();
106        },
107
108        //check the queue asynchronously
109        run: function() {
110            if ($.fn.appear.timeout) clearTimeout($.fn.appear.timeout);
111            $.fn.appear.timeout = setTimeout($.fn.appear.checkAll, 20);
112        }
113    });
114
115    //run checks when these methods are called
116    $.each(['append', 'prepend', 'after', 'before', 'attr',
117        'removeAttr', 'addClass', 'removeClass', 'toggleClass',
118        'remove', 'css', 'show', 'hide'], function(i, n) {
119        var old = $.fn[n];
120        if (old) {
121            $.fn[n] = function() {
122                var r = old.apply(this, arguments);
123                $.fn.appear.run();
124                return r;
125            }
126        }
127    });
128})(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.