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

textkernel / oneui / 11774677434

11 Nov 2024 08:16AM CUT coverage: 89.083%. Remained the same
11774677434

Pull #1305

github

web-flow
Merge 8d745996e into ef88a3194
Pull Request #1305: chore(deps): update eslint

1387 of 1773 branches covered (78.23%)

Branch coverage included in aggregate %.

3411 of 3613 relevant lines covered (94.41%)

60.62 hits per line

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

35.29
/src/utils/scrollIntoViewIfNeeded.js
1
/** TODO: extend this function to check on parent scroll container if we have a use case.
2
 * That implementation is hard to test in storybook because of the iframe situation,
3
 * hence relevant code is now disabled here
4
 */
5

6
// const REGEXP_SCROLL_PARENT = /^(visible|hidden)/;
7

8
// const getScrollParent = el => {
9
//     if (!(el instanceof HTMLElement) || typeof window.getComputedStyle !== 'function') {
10
//         return null;
11
//     }
12
//     if (
13
//         el.scrollHeight >= el.clientHeight &&
14
//         !REGEXP_SCROLL_PARENT.test(window.getComputedStyle(el).overflowY || 'visible')
15
//     ) {
16
//         return el;
17
//     }
18
//     return getScrollParent(el.parentElement) || document.body;
19
// };
20

21
export const scrollIntoViewIfNeeded = (el, alignTo = 'bottom') => {
101!
22
    // check if we can scroll at all
23
    if (!el || !el.scrollIntoView) {
14!
24
        return;
14✔
25
    }
26

27
    // check if element is visible:
28
    const elRect = el.getBoundingClientRect();
×
29
    // const scrollParent = getScrollParent(el);
30
    // const parentRect = scrollParent.getBoundingClientRect();
31

32
    const isVisible = elRect.top >= 0 && elRect.bottom <= window.innerHeight;
×
33
    // const isVisible = elRect.top >= parentRect.top && elRect.bottom <= parentRect.bottom;
34

35
    if (!isVisible) {
×
36
        const alignToTop = alignTo !== 'bottom';
×
37
        el.scrollIntoView(alignToTop);
×
38
    }
39
};
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