PageSourceSearch

https://cosibella.sk/blog/wp-content/themes/blog-wordpress/js/libs/scrollToTop.js

js cosibella.sk collected 2026-10-04 08:21:04 UTC 847 bytes, 32 lines download raw bytes

1const createArrow = () => {
2    const arrow = document.createElement('button');
3    arrow.classList.add('scroll_top');
4    document.body.appendChild(arrow);
5    arrow.addEventListener('click', () => {
6        window.scrollTo({
7            top: 0,
8            behavior: 'smooth'
9        });
10    })
11    return arrow;
12}
13
14const scrollToTop = () => {
15    const button = createArrow();
16    window.addEventListener('scroll', () => {
17
18        const documentHeight = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
19
20        const halfWindowHeight = documentHeight / 2;
21        const scrollPosition = window.scrollY;
22
23        if (scrollPosition >= halfWindowHeight) {
24            button.classList.add("--active");
25        } else {
26            button.classList.remove("--active");
27        }
28
29    })
30}
31
32export default scrollToTop;

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.