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

worktile / ngx-gantt / 56afc371-2b0e-462c-80c7-441d1a207ba1

06 Mar 2024 10:45AM CUT coverage: 71.745%. Remained the same
56afc371-2b0e-462c-80c7-441d1a207ba1

push

circleci

web-flow
build: bump angular 17 #INFR-11782 (#441)

344 of 598 branches covered (57.53%)

Branch coverage included in aggregate %.

3 of 3 new or added lines in 1 file covered. (100.0%)

1403 of 1837 relevant lines covered (76.37%)

932.38 hits per line

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

15.79
/packages/gantt/src/utils/drag-scroll.ts
1
/** Horizontal direction in which we can auto-scroll. */
2
export const enum AutoScrollHorizontalDirection {
3
    NONE,
4
    LEFT,
5
    RIGHT
6
}
7

8
/**
9
 * Proximity, as a ratio to width/height at which to start auto-scrolling the drop list or the
10
 * viewport. The value comes from trying it out manually until it feels right.
11
 */
12
const SCROLL_PROXIMITY_THRESHOLD = 0.05;
1✔
13

14
/**
15
 * Gets whether the horizontal auto-scroll direction of a node.
16
 * @param clientRect Dimensions of the node.
17
 * @param pointerX Position of the user's pointer along the x axis.
18
 */
19
export function getHorizontalScrollDirection(clientRect: DOMRect, pointerX: number) {
20
    const { left, right, width } = clientRect;
×
21
    const xThreshold = width * SCROLL_PROXIMITY_THRESHOLD;
×
22

23
    if (pointerX >= left - xThreshold && pointerX <= left + xThreshold) {
×
24
        return AutoScrollHorizontalDirection.LEFT;
×
25
    } else if (pointerX >= right - xThreshold && pointerX <= right + xThreshold) {
×
26
        return AutoScrollHorizontalDirection.RIGHT;
×
27
    }
28

29
    return AutoScrollHorizontalDirection.NONE;
×
30
}
31

32
/**
33
 * Checks whether the pointer coordinates are close to a ClientRect.
34
 * @param rect ClientRect to check against.
35
 * @param threshold Threshold around the ClientRect.
36
 * @param pointerX Coordinates along the X axis.
37
 * @param pointerY Coordinates along the Y axis.
38
 */
39
export function isPointerNearClientRect(rect: DOMRect, threshold: number, pointerX: number, pointerY: number): boolean {
40
    const { top, right, bottom, left, width, height } = rect;
1✔
41
    const xThreshold = width * threshold;
1✔
42
    const yThreshold = height * threshold;
1✔
43

44
    return pointerY > top - yThreshold && pointerY < bottom + yThreshold && pointerX > left - xThreshold && pointerX < right + xThreshold;
1!
45
}
46

47
/**
48
 * Gets the speed rate of auto scrolling
49
 * @param clientRect Dimensions of the node.
50
 * @param pointerX Position of the user's pointer along the x axis.
51
 * @param horizontalScrollDirection The direction in which the mouse is dragged horizontally
52
 */
53
export function getAutoScrollSpeedRates(clientRect: DOMRect, pointerX: number, horizontalScrollDirection: AutoScrollHorizontalDirection) {
54
    let autoScrollSpeedRates = 4;
×
55
    const speedLevels = 4;
×
56
    const { left, right, width } = clientRect;
×
57
    const xThreshold = width * SCROLL_PROXIMITY_THRESHOLD;
×
58

59
    if (horizontalScrollDirection === AutoScrollHorizontalDirection.LEFT) {
×
60
        autoScrollSpeedRates = Math.ceil((xThreshold - (pointerX > left ? pointerX - left : 0)) / (xThreshold / speedLevels));
×
61
    }
62
    if (horizontalScrollDirection === AutoScrollHorizontalDirection.RIGHT) {
×
63
        autoScrollSpeedRates = Math.ceil((xThreshold - (right > pointerX ? right - pointerX : 0)) / (xThreshold / speedLevels));
×
64
    }
65

66
    return autoScrollSpeedRates;
×
67
}
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