PageSourceSearch

https://ligalife.com.ua/template/js/menu/contactstop_stick.js

js ligalife.com.ua collected 2026-10-02 13:32:07 UTC 2,883 bytes, 73 lines download raw bytes

1$(document).ready(function() {
2    var $window = $(window);
3    var $header = $("#contactstop");
4    var $content = $("#content");
5    var $topPart = $("#contactstop_content1");
6    // Добавляем переменную для второй части, чтобы проверять её наличие
7    var $bottomPart = $("#contactstop_content2");
8
9    if (!$header.length || !$content.length) return;
10
11    var topPartHeight = 0;
12    var headerHeight = 0;
13
14    function updateDimensions() {
15        topPartHeight = $topPart.length ? $topPart.outerHeight() : 0;
16        headerHeight = $header.outerHeight();
17        onScroll();
18    }
19
20    function onScroll() {
21        var scrollTop = $window.scrollTop();
22        
23        // ПРОВЕРКА: Есть ли вторая часть шапки?
24        var hasBottomPart = $bottomPart.length > 0;
25
26        // ЛОГИКА ТРИГГЕРА:
27        // Если есть вторая часть, ждем пока проскроллится первая (topPartHeight).
28        // Если второй части нет, фиксируем сразу как только начали скроллить (0).
29        var triggerPoint = hasBottomPart ? topPartHeight : 0;
30
31        // ЛОГИКА СДВИГА:
32        // Если есть вторая часть, сдвигаем шапку вверх на высоту первой (-topPartHeight).
33        // Если второй части нет, не сдвигаем ничего (0), чтобы шапка была видна целиком.
34        var offsetTop = hasBottomPart ? topPartHeight : 0;
35
36        // Добавляем условие: scrollTop > triggerPoint.
37        // Для варианта без второй части можно добавить scrollTop > 0, чтобы не фиксировать на самом верху, если это не нужно.
38        if (scrollTop >= triggerPoint && headerHeight > 0) 
39        {
40            $header.css({
41                'position': 'fixed',
42                'top': '-' + offsetTop + 'px', // Используем вычисленный сдвиг
43                'width': '100%',
44                'z-index': '1000'
45            });
46            $content.css('marginTop', headerHeight + 'px');
47            
48            if (window.stickySidebarInstance) 
49            {
50                window.stickySidebarInstance.updateSticky();
51            }
52        } 
53        else 
54        {
55            $header.css({
56                'position': 'relative',
57                'top': '0px',
58                'width': '',
59                'z-index': ''
60            });
61            $content.css('marginTop', '0px');
62        }
63    }
64
65    $window.on('resize', updateDimensions);
66    $window.on('scroll', onScroll);
67    
68    $window.on('load', function() {
69        updateDimensions();
70    });
71
72    updateDimensions();
73});

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.