PageSourceSearch

https://createur2site.fr/wp-content/themes/C2S/scrollbar/js/scrollbar.js?ver=4.66.31

js createur2site.fr collected 2026-09-26 13:04:38 UTC 4,208 bytes, 137 lines download raw bytes

1'use strict';
2
3(function () {
4    var scrollbar, track, thumb;
5    var hideTimer = null;
6    var isDragging = false;
7    var dragStartY = 0;
8    var dragStartScroll = 0;
9
10    function create() {
11        scrollbar = document.createElement('div');
12        scrollbar.className = 'c2s-scrollbar';
13
14        track = document.createElement('div');
15        track.className = 'c2s-scrollbar__track';
16
17        thumb = document.createElement('div');
18        thumb.className = 'c2s-scrollbar__thumb';
19
20        track.appendChild(thumb);
21        scrollbar.appendChild(track);
22        document.body.appendChild(scrollbar);
23
24        track.addEventListener('click', onTrackClick);
25        thumb.addEventListener('mousedown', onDragStart);
26        document.addEventListener('mousemove', onDragMove);
27        document.addEventListener('mouseup', onDragEnd);
28        thumb.addEventListener('touchstart', onTouchStart, { passive: false });
29        document.addEventListener('touchmove', onTouchMove, { passive: false });
30        document.addEventListener('touchend', onDragEnd);
31    }
32
33    function update(progress, limit) {
34        if (!thumb) return;
35        var vh = window.innerHeight;
36        var total = limit + vh;
37        var ratio = vh / total;
38        var thumbH = Math.max(ratio * 100, 3);
39        thumb.style.height = thumbH + '%';
40        thumb.style.top = (progress * (100 - thumbH)) + '%';
41    }
42
43    function show() {
44        if (!scrollbar) return;
45        scrollbar.classList.add('is-visible');
46        clearTimeout(hideTimer);
47        hideTimer = setTimeout(function () {
48            if (!isDragging) scrollbar.classList.remove('is-visible');
49        }, 1200);
50    }
51
52    function onTrackClick(e) {
53        if (isDragging) return;
54        var lenis = window._c2sLenis;
55        if (!lenis) return;
56        var rect = track.getBoundingClientRect();
57        var ratio = (e.clientY - rect.top) / rect.height;
58        lenis.scrollTo(ratio * lenis.limit);
59    }
60
61    function onDragStart(e) {
62        e.preventDefault();
63        isDragging = true;
64        dragStartY = e.clientY;
65        var lenis = window._c2sLenis;
66        dragStartScroll = lenis ? lenis.scroll : 0;
67        scrollbar.classList.add('is-dragging');
68    }
69
70    function onTouchStart(e) {
71        e.preventDefault();
72        isDragging = true;
73        dragStartY = e.touches[0].clientY;
74        var lenis = window._c2sLenis;
75        dragStartScroll = lenis ? lenis.scroll : 0;
76        scrollbar.classList.add('is-dragging');
77    }
78
79    function onDragMove(e) {
80        if (!isDragging) return;
81        var lenis = window._c2sLenis;
82        if (!lenis) return;
83        var rect = track.getBoundingClientRect();
84        var clientY = e.clientY !== undefined ? e.clientY : 0;
85        var delta = clientY - dragStartY;
86        var scrollDelta = (delta / rect.height) * lenis.limit;
87        lenis.scrollTo(dragStartScroll + scrollDelta, { immediate: true });
88    }
89
90    function onTouchMove(e) {
91        if (!isDragging) return;
92        var lenis = window._c2sLenis;
93        if (!lenis) return;
94        var rect = track.getBoundingClientRect();
95        var delta = e.touches[0].clientY - dragStartY;
96        var scrollDelta = (delta / rect.height) * lenis.limit;
97        lenis.scrollTo(dragStartScroll + scrollDelta, { immediate: true });
98    }
99
100    function onDragEnd() {
101        if (!isDragging) return;
102        isDragging = false;
103        scrollbar.classList.remove('is-dragging');
104        show();
105    }
106
107    function refresh() {
108        var lenis = window._c2sLenis;
109        if (lenis) update(lenis.progress || 0, lenis.limit);
110    }
111
112    function init() {
113        create();
114
115        var check = setInterval(function () {
116            var lenis = window._c2sLenis;
117            if (!lenis) return;
118            clearInterval(check);
119
120            lenis.on('scroll', function (e) {
121                if (lenis.limit < 10) return;
122                update(e.progress, lenis.limit);
123                show();
124            });
125
126            refresh();
127        }, 100);
128    }
129
130    window.c2sScrollbarRefresh = refresh;
131
132    if (document.readyState === 'loading') {
133        document.addEventListener('DOMContentLoaded', init);
134    } else {
135        init();
136    }
137})();

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.