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

glideapps / glide-data-grid / 7607548630

22 Jan 2024 06:58AM UTC coverage: 92.025% (+0.003%) from 92.022%
7607548630

push

github

jassmith
Start working on trailing freeze column support

2773 of 3399 branches covered (0.0%)

16756 of 18208 relevant lines covered (92.03%)

3194.35 hits per line

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

65.38
/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
        const rectHeight = cell.skeletonHeight ?? Math.min(18, rect.height - 2 * theme.cellVerticalPadding);
×
39

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