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

glideapps / glide-data-grid / 9021282036

09 May 2024 05:44PM CUT coverage: 91.291%. Remained the same
9021282036

Pull #951

github

jeremyll
Fix scrolling by pixels
Pull Request #951: Fix scrolling by pixels

2888 of 3576 branches covered (80.76%)

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

17778 of 19474 relevant lines covered (91.29%)

3114.64 hits per line

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

60.71
/packages/core/src/cells/loading-cell.tsx
1
import { withAlpha } from "../internal/data-grid/color-parser.js";
1✔
2
import { roundedRect } from "../internal/data-grid/render/data-grid-lib.js";
1✔
3
import { GridCellKind, type LoadingCell } from "../internal/data-grid/data-grid-types.js";
1✔
4
import type { InternalCellRenderer } from "./cell-types.js";
1✔
5

1✔
6
// returns a "random" number between -1 and 1
1✔
7
function getRandomNumber(x: number, y: number): number {
×
8
    let seed = x * 49_632 + y * 325_176;
×
9

×
10
    // Inline Xorshift algorithm
×
11
    seed ^= seed << 13;
×
12
    seed ^= seed >> 17;
×
13
    seed ^= seed << 5;
×
14

×
15
    // eslint-disable-next-line unicorn/number-literal-case
×
16
    return (seed / 0xff_ff_ff_ff) * 2;
×
17
}
×
18

1✔
19
export const loadingCellRenderer: InternalCellRenderer<LoadingCell> = {
1✔
20
    getAccessibilityString: () => "",
1✔
21
    kind: GridCellKind.Loading,
1✔
22
    needsHover: false,
1✔
23
    useLabel: false,
1✔
24
    needsHoverPosition: false,
1✔
25
    measure: () => 120,
1✔
26
    draw: a => {
1✔
27
        const { cell, col, row, ctx, rect, theme } = a;
66✔
28
        if (cell.skeletonWidth === undefined || cell.skeletonWidth === 0) {
66!
29
            return;
66✔
30
        }
66!
31

×
32
        let width = cell.skeletonWidth;
×
33
        if (cell.skeletonWidthVariability !== undefined && cell.skeletonWidthVariability > 0) {
66!
34
            width += Math.round(getRandomNumber(col, row) * cell.skeletonWidthVariability);
×
35
        }
×
36

×
37
        const hpad = theme.cellHorizontalPadding;
×
38
        if (width + hpad * 2 >= rect.width) {
×
39
            width = rect.width - hpad * 2 - 1;
×
40
        }
×
41

×
42
        const rectHeight = cell.skeletonHeight ?? Math.min(18, rect.height - 2 * theme.cellVerticalPadding);
×
43

66✔
44
        roundedRect(
66✔
45
            ctx,
66✔
46
            rect.x + hpad,
66✔
47
            rect.y + (rect.height - rectHeight) / 2,
66✔
48
            width,
66✔
49
            rectHeight,
66✔
50
            theme.roundingRadius ?? 3
66!
51
        );
66✔
52
        ctx.fillStyle = withAlpha(theme.textDark, 0.1);
66✔
53
        ctx.fill();
66✔
54
    },
66✔
55
    onPaste: () => undefined,
1✔
56
};
1✔
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