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

react-ui-org / react-ui / 14409123594

11 Apr 2025 05:54PM CUT coverage: 90.674%. First build
14409123594

Pull #601

github

web-flow
Merge 7addc9ab0 into 50391a71a
Pull Request #601: Introduce custom design of `FileInputField` (#244)

802 of 890 branches covered (90.11%)

Branch coverage included in aggregate %.

21 of 34 new or added lines in 1 file covered. (61.76%)

744 of 815 relevant lines covered (91.29%)

74.66 hits per line

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

35.71
/src/components/ScrollView/_hooks/useScrollPositionHook.js
1
import {
2
  useLayoutEffect,
3
  useRef,
4
} from 'react';
5
import { getElementsPositionDifference } from '../_helpers/getElementsPositionDifference';
6

7
export const useScrollPosition = (effect, dependencies, contentEl, viewportEl, wait) => {
8✔
8
  const throttleTimeout = useRef(null);
30✔
9

10
  const callBack = (wasDelayed = false) => {
30!
11
    effect(getElementsPositionDifference(contentEl, viewportEl));
×
12

13
    if (wasDelayed) {
×
14
      throttleTimeout.current = null;
×
15
    }
16
  };
17

18
  useLayoutEffect(() => {
30✔
19
    const viewport = viewportEl.current;
30✔
20

21
    const handleScroll = () => {
30✔
22
      if (wait) {
×
23
        if (throttleTimeout.current === null) {
×
24
          throttleTimeout.current = setTimeout(callBack, wait, true);
×
25
        }
26
      } else {
27
        callBack();
×
28
      }
29
    };
30

31
    viewport.addEventListener('scroll', handleScroll);
30✔
32

33
    return () => {
30✔
34
      clearTimeout(throttleTimeout.current);
30✔
35
      viewport.removeEventListener('scroll', handleScroll);
30✔
36
    };
37
  }, dependencies); // eslint-disable-line react-hooks/exhaustive-deps
38
};
39

40
export default useScrollPosition;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc