• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

geosolutions-it / MapStore2 / 30263629182

27 Jul 2026 11:52AM UTC coverage: 75.764% (-0.03%) from 75.789%
30263629182

Pull #12664

github

web-flow
Merge d4ed16c34 into 85310a94b
Pull Request #12664: Multi View Identify #12595

36066 of 56768 branches covered (63.53%)

165 of 229 new or added lines in 8 files covered. (72.05%)

116 existing lines in 5 files now uncovered.

44874 of 59229 relevant lines covered (75.76%)

123.14 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

79.31
/web/client/hooks/useCheckScroll.js
1
import { useEffect, useRef, useState } from 'react';
2

3
/**
4
 * Provides native horizontal scroll controls for an overflowing element.
5
 * @param {object} options hook options
6
 * @param {any} options.data data that changes the scrollable content
7
 * @return {array} scroll element ref, control visibility, disabled states and scroll action
8
 */
9
export default function useCheckScroll({ data }) {
10
    const scrollRef = useRef(null);
15✔
11
    const [isLeftDisabled, setIsLeftDisabled] = useState(true);
15✔
12
    const [isRightDisabled, setIsRightDisabled] = useState(true);
15✔
13
    const [showButtons, setShowButtons] = useState(false);
15✔
14

15
    useEffect(() => {
15✔
16
        const handleScroll = () => {
15✔
17
            const element = scrollRef.current;
15✔
18
            if (!element) {
15!
NEW
19
                return;
×
20
            }
21

22
            const { scrollLeft, scrollWidth, clientWidth } = element;
15✔
23
            const canScroll = scrollWidth > clientWidth + 1;
15✔
24
            setShowButtons(canScroll);
15✔
25
            setIsLeftDisabled(scrollLeft <= 0);
15✔
26
            setIsRightDisabled(scrollLeft + clientWidth >= scrollWidth - 1);
15✔
27
        };
28

29
        const element = scrollRef.current;
15✔
30
        if (element) {
15!
31
            handleScroll();
15✔
32
            element.addEventListener('scroll', handleScroll);
15✔
33
            window.addEventListener('resize', handleScroll);
15✔
34
        }
35

36
        return () => {
15✔
37
            element?.removeEventListener('scroll', handleScroll);
15✔
38
            window.removeEventListener('resize', handleScroll);
15✔
39
        };
40
    }, [data, showButtons]);
41

42
    const scroll = (direction) => {
15✔
NEW
43
        const element = scrollRef.current;
×
NEW
44
        if (!element) {
×
NEW
45
            return;
×
46
        }
NEW
47
        const scrollAmount = element.clientWidth * 0.8;
×
NEW
48
        element.scrollBy({
×
49
            left: direction === 'left' ? -scrollAmount : scrollAmount,
×
50
            behavior: 'smooth'
51
        });
52
    };
53

54
    return [scrollRef, showButtons, isLeftDisabled, isRightDisabled, scroll];
15✔
55
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc