PageSourceSearch

https://inlinks.com/wp-content/plugins/sticky-header-effects-for-elementor/assets/js/she-header.js?ver=2.2.1

js inlinks.com collected 2026-09-24 18:44:22 UTC 17,089 bytes, 412 lines download raw bytes

1var $j = jQuery.noConflict();
2
3$j(document).ready(function () {
4    "use strict";
5    // She header
6    sheHeader();
7
8    // Debounce resize: sheHeader() re-runs the full per-header setup and
9    // rebinds every scroll listener, so firing it on every resize pixel is
10    // wasteful (and janky on devices that stream resize events). Run it once
11    // the resize settles instead.
12    var sheResizeTimer;
13    $j(window).on('resize', function (e) {
14        clearTimeout(sheResizeTimer);
15        sheResizeTimer = setTimeout(function () {
16            sheHeader(e);
17        }, 150);
18    });
19});
20
21
22/* ==============================================
23HEADER EFFECTS
24============================================== */
25
26
27function sheHeader(e) {
28
29    // Iterate each sticky header independently so that multiple sticky headers
30    // each use their OWN settings/scroll-distance instead of all sharing the
31    // first matched header's settings (the "sticks too early" group bug).
32    $j('.elementor-element.she-header-yes').each(function (sheIndex) {
33
34    var header = $j(this),
35        container = header.find('.elementor-container').add(header.filter('.e-con')),
36        header_elementor = header.closest('.elementor-edit-mode').length ? header : $j(),
37        header_logo = header.find('.elementor-widget-theme-site-logo img:not(.elementor-widget-n-menu img), .elementor-widget-image img:not(.elementor-widget-n-menu img)'),
38        header_logo_div = header.find('.elementor-widget-theme-site-logo a, .elementor-widget-image a'),
39        data_settings = header.data('settings');
40
41    if (typeof data_settings != 'undefined') {
42        var responsive_settings = data_settings["transparent_on"];
43        var width = $j(window).width(),
44            header_height = header.height(),
45            logo_width = header_logo.width(),
46            logo_height = header_logo.height();
47    }
48
49    // Check responsive is enabled
50    if (typeof width != 'undefined' && width) {
51        if (width >= 1025) {
52            var enabled = "desktop";
53        } else if (width > 767 && width < 1025) {
54            var enabled = "tablet";
55        } else if (width <= 767) {
56            var enabled = "mobile";
57        }
58    }
59
60    if ($j.inArray(enabled, responsive_settings) !== -1) {
61
62        var scroll_distance = data_settings["scroll_distance"];
63        var she_offset = data_settings["she_offset_top"];
64        var she_padding = data_settings["she_padding"];
65        var she_width = data_settings["she_width"];
66        var transparent_header = data_settings["transparent_header_show"];
67        var background = data_settings["background"];
68        var bottom_border_color = data_settings["custom_bottom_border_color"],
69            bottom_border_view = data_settings["bottom_border"],
70            bottom_border_width = data_settings["custom_bottom_border_width"];
71
72        var shrink_header = data_settings["shrink_header"],
73            data_height = data_settings["custom_height_header"],
74            data_height_tablet = data_settings["custom_height_header_tablet"],
75            data_height_mobile = data_settings["custom_height_header_mobile"];
76
77        var shrink_logo = data_settings["shrink_header_logo"],
78            data_logo_height = data_settings["custom_height_header_logo"],
79            data_logo_height_tablet = data_settings["custom_height_header_logo_tablet"],
80            data_logo_height_mobile = data_settings["custom_height_header_logo_mobile"];
81
82        var change_logo_color = data_settings["change_logo_color"];
83
84        var blur_bg = data_settings["blur_bg"];
85
86        var scroll_distance_hide_header = data_settings["scroll_distance_hide_header"];
87
88        // offset
89        if (width >= 1025) {
90            she_offset = data_settings["she_offset_top"];
91            she_padding = data_settings["she_padding"];
92            she_width = data_settings["she_width"];
93        } else if (width > 767 && width < 1025) {
94            she_offset = data_settings["she_offset_top_tablet"];
95            she_padding = data_settings["she_padding_tablet"];
96            she_width = data_settings["she_width_tablet"];
97        } else if (width <= 767) {
98            she_offset = data_settings["she_offset_top_mobile"];
99            she_padding = data_settings["she_padding_mobile"];
100            she_width = data_settings["she_width_mobile"];
101        }
102
103        if (header.hasClass("she-header")) {
104            if( e?.type === 'resize' ){
105                header.css("width", she_width.size + she_width.unit);
106                header.css("padding-top", she_padding.top + she_padding.unit);
107                header.css("padding-bottom", she_padding.bottom + she_padding.unit);
108                header.css("padding-left", she_padding.left + she_padding.unit);
109                header.css("padding-right", she_padding.right + she_padding.unit);
110            }
111        }
112
113        // add transparent class
114        if (transparent_header == "yes") {
115            header.addClass('she-header-transparent-yes');
116        }
117
118        // header height shrink
119        if (typeof data_height != "undefined" && data_height) {
120            if (width >= 1025) {
121                var shrink_height = data_height["size"];
122            } else if (width > 767 && width < 1025) {
123                var shrink_height = data_height_tablet["size"];
124                if (shrink_height == "") {
125                    shrink_height = data_height["size"];
126                }
127            } else if (width <= 767) {
128                var shrink_height = data_height_mobile["size"];
129                if (shrink_height == "") {
130                    shrink_height = data_height["size"];
131                }
132            }
133        }
134
135        // Logo height shrink
136        if (
137            typeof data_logo_height != "undefined" &&
138            data_logo_height
139        ) {
140            if (width >= 1025) {
141                var shrink_logo_height = data_logo_height["size"];
142            } else if (width > 767 && width < 1025) {
143                var shrink_logo_height =
144                    data_logo_height_tablet["size"];
145            } else if (width <= 767) {
146                var shrink_logo_height =
147                    data_logo_height_mobile["size"];
148            }
149
150            //Calc New width and height
151            if (shrink_logo_height == "") {
152                //Get logo shrink settings from desktop
153                shrink_logo_height = data_logo_height["size"];
154
155                if (shrink_logo_height == "") {
156                    // Shrink same settings from height shrink option
157                    shrink_logo_height = shrink_height;
158
159                    var percent =
160                        parseInt(shrink_logo_height) /
161                        parseInt(header_height),
162                        width_l = logo_width * percent,
163                        height_l = logo_height * percent;
164                } else {
165                    var width_l =
166                        (logo_width * shrink_logo_height) / 100,
167                        height_l =
168                            (logo_height * shrink_logo_height) / 100;
169                }
170            } else {
171                //Get logo shrink settings from the responsive option
172                var width_l = (logo_width * shrink_logo_height) / 100,
173                    height_l = (logo_height * shrink_logo_height) / 100;
174            }
175        }
176
177        // border bottom
178        if (typeof bottom_border_width != 'undefined' && bottom_border_width) {
179            var bottom_border = bottom_border_width["size"] + "px solid " + bottom_border_color;
180        }
181
182        // hide header on scroll
183        if (
184            typeof scroll_distance_hide_header != "undefined" &&
185            scroll_distance_hide_header
186        ) {
187            var mywindow = $j(window),
188                mypos = mywindow.scrollTop();
189
190            mywindow.off('scroll.sheHide' + sheIndex).on('scroll.sheHide' + sheIndex, function () {
191                var sd_hh_s = scroll_distance_hide_header["size"],
192                    sd_hh_u = scroll_distance_hide_header["unit"],
193                    sd_hh_tablet =
194                        data_settings[
195                        "scroll_distance_hide_header_tablet"
196                        ],
197                    sd_hh_tablet_s = sd_hh_tablet["size"],
198                    sd_hh_tablet_u = sd_hh_tablet["unit"],
199                    sd_hh_mobile =
200                        data_settings[
201                        "scroll_distance_hide_header_mobile"
202                        ],
203                    sd_hh_mobile_s = sd_hh_mobile["size"],
204                    sd_hh_mobile_u = sd_hh_mobile["unit"];
205
206                // get responsive view
207                if (
208                    typeof scroll_distance_hide_header != "undefined" &&
209                    scroll_distance_hide_header
210                ) {
211                    if (width >= 1025) {
212                        var sd_hh = sd_hh_s,
213                            sd_hh_u = sd_hh_u;
214                        // calc sise for vh unit
215                        if (sd_hh_u == "vh") {
216                            sd_hh = window.innerHeight * (sd_hh / 100);
217                        }
218                    } else if (width > 767 && width < 1025) {
219                        var sd_hh = sd_hh_tablet_s,
220                            sd_hh_u = sd_hh_tablet_u;
221
222                        if (sd_hh == "") {
223                            sd_hh = sd_hh_s;
224                        }
225                        // calc sise for vh unit
226                        if (sd_hh_u == "vh") {
227                            sd_hh = window.innerHeight * (sd_hh / 100);
228                        }
229                    } else if (width <= 767) {
230                        var sd_hh = sd_hh_mobile_s,
231                            sd_hh_u = sd_hh_mobile_u;
232
233                        if (sd_hh == "") {
234                            sd_hh = sd_hh_s;
235                        }
236                        // calc sise for vh unit
237                        if (sd_hh_u == "vh") {
238                            sd_hh = window.innerHeight * (sd_hh / 100);
239                        }
240                    }
241                }
242
243                // added option for vh unit
244                //if(sd_hh_u == 'px'){
245                //	sd_hh  = sd_hh_s;
246                //} else {
247                //	sd_hh  = (window.innerHeight)*(sd_hh_s/100);
248                //}
249
250                if (mypos > sd_hh) {
251                    if (mywindow.scrollTop() > mypos) {
252                        header.addClass("headerup");
253                    } else {
254                        header.removeClass("headerup");
255                    }
256                }
257                mypos = mywindow.scrollTop();
258            });
259        }
260
261        // scroll function — throttled with requestAnimationFrame so the
262        // heavy per-property style writes below run at most once per frame.
263        var she_scroll_ticking = false;
264        $j(window).off("load.sheScroll" + sheIndex + " scroll.sheScroll" + sheIndex).on("load.sheScroll" + sheIndex + " scroll.sheScroll" + sheIndex, function (e) {
265            if (she_scroll_ticking) {
266                return;
267            }
268            she_scroll_ticking = true;
269            requestAnimationFrame(function () {
270                she_scroll_ticking = false;
271            var scroll = $j(window).scrollTop();
272
273            if (header_elementor.length) {
274                header_elementor.css("position", "relative");
275            }
276
277            var sd_s = scroll_distance["size"],
278                sd_u = scroll_distance["unit"],
279                sd_tablet = data_settings["scroll_distance_tablet"],
280                sd_tablet_s = sd_tablet["size"],
281                sd_tablet_u = sd_tablet["unit"],
282                sd_mobile = data_settings["scroll_distance_mobile"],
283                sd_mobile_s = sd_mobile["size"],
284                sd_mobile_u = sd_mobile["unit"];
285
286            // get responsive view
287            if (
288                typeof scroll_distance != "undefined" &&
289                scroll_distance
290            ) {
291                if (width >= 1025) {
292                    var sd = sd_s,
293                        sd_u = sd_u;
294                    // calc sise for vh unit
295                    if (sd_u == "vh") {
296                        sd = window.innerHeight * (sd / 100);
297                    }
298                } else if (width > 767 && width < 1025) {
299                    var sd = sd_tablet_s,
300                        sd_u = sd_tablet_u;
301
302                    if (sd == "") {
303                        sd = sd_s;
304                    }
305                    // calc sise for vh unit
306                    if (sd_u == "vh") {
307                        sd = window.innerHeight * (sd / 100);
308                    }
309                } else if (width <= 767) {
310                    var sd = sd_mobile_s,
311                        sd_u = sd_mobile_u;
312
313                    if (sd == "") {
314                        sd = sd_s;
315                    }
316                    // calc sise for vh unit
317                    if (sd_u == "vh") {
318                        sd = window.innerHeight * (sd / 100);
319                    }
320                }
321            }
322
323            if (scroll >= sd) {
324                header.removeClass('header').addClass("she-header");
325                header.css("background-color", background);
326                header.css("border-bottom", bottom_border);
327
328                // Multi-Sticky (Pro) manages its own top / width / padding via a
329                // placeholder spacer. Skip Free's geometry writes for those
330                // containers so the two don't fight (cosmetic background/border
331                // above still apply). Pure-Free headers have no
332                // data-she-multi-mode attribute and get the full treatment.
333                if (!header.attr("data-she-multi-mode")) {
334                    header.css("top", she_offset.size + she_offset.unit);
335
336                    if (width >= 783 && document.body.classList.contains('admin-bar')) {
337                        if (she_offset.unit === 'px') {
338                            header.css("top", (32 + she_offset.size) + "px");
339                        } else {
340                            header.css("top", "calc(32px + " + she_offset.size + she_offset.unit + ")");
341                        }
342                    }
343
344                    header.css("padding-top", she_padding.top + she_padding.unit);
345                    header.css("padding-bottom", she_padding.bottom + she_padding.unit);
346                    header.css("padding-left", she_padding.left + she_padding.unit);
347                    header.css("padding-right", she_padding.right + she_padding.unit);
348                    header.css("width", she_width.size + she_width.unit);
349                }
350
351                header.removeClass('she-header-transparent-yes');
352
353                if (shrink_header == "yes") {
354                    header.css({ "padding-top": "0", "padding-bottom": "0", "margin-top": "0", "margin-bottom": "0" });
355                    container.css({ "min-height": shrink_height, "transition": "all 0.4s ease-in-out", "
355-webkit-transition": "all 0.4s ease-in-out", "-moz-transition": "all 0.4s ease-in-out" });
356                }
357
358                if (change_logo_color == "yes") {
359                    header_logo.addClass("change-logo-color");
360                }
361
362                // ---------------------------------- SHRINK LOGO
363                if (shrink_logo == "yes") {
364                    header_logo.css({
365                        width: width_l,
366                        transition: "all 0.4s ease-in-out",
367                        "-webkit-transition": "all 0.4s ease-in-out",
368                        "-moz-transition": "all 0.4s ease-in-out",
369                    });
370                }
371
372            } else {
373                header.removeClass("she-header").addClass('header');
374                header.css("background-color", "");
375                header.css("border-bottom", "");
376                if (!header.attr("data-she-multi-mode")) {
377                    header.css("top", "");
378                    header.css("padding-top", "");
379                    header.css("padding-bottom", "");
380                    header.css("padding-left", "");
381                    header.css("padding-right", "");
382                    header.css("width", "");
383                }
384
385                if (transparent_header == "yes") {
386                    header.addClass('she-header-transparent-yes');
387                }
388                if (shrink_header == "yes") {
389                    header.css({ "padding-top": "", "padding-bottom": "", "margin-top": "", "margin-bottom": "" });
390                    container.css("min-height", "");
391                }
392
393                // ---------------------------------- SHRINK LOGO
394                if (shrink_logo == "yes") {
395                    header_logo.css({ height: "", width: "" });
396                }
397
398                if (change_logo_color == "yes") {
399                    header_logo.removeClass("change-logo-color");
400
401                }
402
403            }
404
405
406            }); // end requestAnimationFrame
407        });
408    }
409
410    }); // end .each — per sticky-header iteration
411
412};

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.