PageSourceSearch

https://www.somospacientes.com/wp-content/themes/somospacientes-20…as-slider-conocenos.js?ver=0.1.1.1759844762

js somospacientes.com collected 2026-10-02 06:57:53 UTC 4,470 bytes, 148 lines download raw bytes

1document.addEventListener('DOMContentLoaded', function () {
2    const swiper = new Swiper('.swiper', {
3
4        direction: 'horizontal',
5        loop: false,
6        nested: true,
7        spaceBetween: 20,
8        slidesperview: 2,
9        freeMode: {
10            enable: true,
11            sticky: true,
12        },
13        pagination: {
14            el: '.swiper-pagination',
15        },
16        mousewheel: {
17            enabled: true,
18            releaseOnEdges: true,
19            sensitivity: 1,
20        },
21        on: {
22
23            fromEdge: function () {
24
25                window.scrollTo(0, jQuery('.swiper').offset().top);
26
27
28            },
29        },
30
31    });
32
33
34    setTimeout(1000, add_scroll_event_desktop(swiper));
35
36
37});
38
39
40
41function add_scroll_event_desktop(swiper_contenidos_web) {
42    let horizontalScrollProgress = 0;
43    let isInHorizontalMode = false;
44    let scrollBuffer = 0;
45    let isTransitioning = false;
46
47    const swiperContainer = jQuery('.swiper');
48    const swiperWrapper = jQuery('.swiper-wrapper');
49    const slides = jQuery('.swiper-slide');
50
51    if (!swiperContainer.length) return;
52
53    swiperWrapper.css({
54        'display': 'flex',
55        'transition': 'transform 0.3s ease',
56        'width': (slides.length * 100) + '%'
57    });
58
59    slides.css({
60        'flex': '0 0 auto',
61        'width': (100 / slides.length) + '%'
62    });
63
64    const totalSlides = slides.length;
65    const maxProgress = totalSlides - 1;
66
67    function updateHorizontalPosition() {
68        const percentage = (horizontalScrollProgress / maxProgress) * 100;
69        swiperWrapper.css('transform', `translateX(-${percentage}%)`);
70    }
71
72    function lockScrollPosition() {
73        if (isTransitioning) return;
74
75        isTransitioning = true;
76        const swiperTop = swiperContainer.offset().top;
77        const windowHeight = jQuery(window).height();
78        const targetScroll = swiperTop - windowHeight / 2;
79
80        jQuery('html, body').stop().animate({
81            scrollTop: targetScroll
82        }, 200, function () {
83            isTransitioning = false;
84        });
85    }
86
87    jQuery(window).on('scroll', function (e) {
88        const scrollTop = jQuery(this).scrollTop();
89        const swiperTop = swiperContainer.offset().top;
90        const windowHeight = jQuery(window).height();
91        const swiperHeight = swiperContainer.outerHeight();
92
93        const enterThreshold = swiperTop - windowHeight / 2;
94        const exitThreshold = swiperTop + swiperHeight - windowHeight / 2;
95
96        const shouldEnterHorizontalMode = scrollTop >= enterThreshold && scrollTop <= exitThreshold;
97
98        if (shouldEnterHorizontalMode && !isInHorizontalMode) {
99            isInHorizontalMode = true;
100            lockScrollPosition();
101        } else if (!shouldEnterHorizontalMode && isInHorizontalMode) {
102            // Exit horizontal mode immediately when conditions are met
103            isInHorizontalMode = false;
104        }
105    });
106
107    jQuery(window).on('wheel', function (e) {
108        if (!isInHorizontalMode) return;
109
110        e.preventDefault();
111        e.stopPropagation();
112
113        const delta = e.originalEvent.deltaY;
114
115        // Accumulate scroll delta for smoother movement
116        scrollBuffer += delta;
117
118        // Apply horizontal scroll when buffer reaches threshold
119        if (Math.abs(scrollBuffer) > 50) {
120            const direction = scrollBuffer > 0 ? 1 : -1;
121            horizontalScrollProgress += direction * 0.5;
122            horizontalScrollProgress = Math.max(0, Math.min(horizontalScrollProgress, maxProgress));
123            updateHorizontalPosition();
124
125            // Reset buffer
126            scrollBuffer = 0;
127
128            // Check if we've reached the ends and allow immediate exit
129            if (horizontalScrollProgress >= maxProgress && direction > 0) {
130                // Reached end and scrolling down - exit immediately
131                isInHorizontalMode = false;
132            } else if (horizontalScrollProgress <= 0 && direction < 0) {
133                // Reached beginning and scrolling up - exit immediately
134                isInHorizontalMode = false;
135            }
136        }
137
138        return false;
139    }, { passive: false });
140
141    // Prevent other scroll events when in horizontal mode
142    jQuery(document).on('keydown', function (e) {
143        if (isInHorizontalMode && (e.key === 'ArrowUp' || e.key === 'ArrowDown' || e.key === ' ' || e.key === 'PageUp' || e.key === 'PageDown')) {
144            e.preventDefault();
145        }
146    });
147}
148

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.