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

react-ui-org / react-ui / 16515684792

25 Jul 2025 06:45AM UTC coverage: 59.662%. First build
16515684792

Pull #649

github

web-flow
Merge 598129bc9 into 63d6139bc
Pull Request #649: Transform scrollview jest tests into playwright (#598)

101 of 199 branches covered (50.75%)

Branch coverage included in aggregate %.

146 of 215 relevant lines covered (67.91%)

7.08 hits per line

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

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

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

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

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

18
  useLayoutEffect(() => {
2✔
19
    const handleLoadResize = () => {
2✔
20
      if (wait) {
×
21
        if (throttleTimeout.current === null) {
×
22
          throttleTimeout.current = setTimeout(callBack, wait, true);
×
23
        }
24
      } else {
25
        callBack();
×
26
      }
27
    };
28

29
    window.addEventListener('load', handleLoadResize);
2✔
30
    window.addEventListener('resize', handleLoadResize);
2✔
31

32
    return () => {
2✔
33
      clearTimeout(throttleTimeout.current);
2✔
34
      window.removeEventListener('load', handleLoadResize);
2✔
35
      window.removeEventListener('resize', handleLoadResize);
2✔
36
    };
37
  }, dependencies); // eslint-disable-line react-hooks/exhaustive-deps
38
};
39

40
export default useLoadResize;
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