• 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

11.48
/packages/core/src/internal/data-grid/render/draw-edit-hover-indicator.ts
1
import type { FullTheme } from "../../../common/styles.js";
1✔
2
import type { Rectangle, HoverEffectTheme } from "../../../index.js";
1✔
3
import { roundedRect, measureTextCached } from "./data-grid-lib.js";
1✔
4
import { withAlpha } from "../color-parser.js";
1✔
5

1✔
6
export function drawEditHoverIndicator(
1✔
7
    ctx: CanvasRenderingContext2D,
×
8
    theme: FullTheme,
×
9
    effectTheme: HoverEffectTheme | undefined,
×
10
    displayData: string,
×
11
    rect: Rectangle,
×
12
    hoverAmount: number,
×
13
    overrideCursor: ((cursor: React.CSSProperties["cursor"] | undefined) => void) | undefined
×
14
) {
×
15
    ctx.textBaseline = "alphabetic";
×
16

×
17
    const effectRect = getHoverEffectRect(ctx, rect, displayData, theme, effectTheme?.fullSize ?? false);
×
18

×
19
    ctx.beginPath();
×
20
    roundedRect(ctx, effectRect.x, effectRect.y, effectRect.width, effectRect.height, theme.roundingRadius ?? 4);
×
21
    ctx.globalAlpha = hoverAmount;
×
22
    ctx.fillStyle = effectTheme?.bgColor ?? withAlpha(theme.textDark, 0.1);
×
23
    ctx.fill();
×
24

×
25
    // restore
×
26
    ctx.globalAlpha = 1;
×
27
    ctx.fillStyle = theme.textDark;
×
28
    ctx.textBaseline = "middle";
×
29

×
30
    overrideCursor?.("text");
×
31
}
×
32

1✔
33
function getHoverEffectRect(
×
34
    ctx: CanvasRenderingContext2D,
×
35
    cellRect: Rectangle,
×
36
    displayData: string,
×
37
    theme: FullTheme,
×
38
    fullSize: boolean
×
39
): Rectangle {
×
40
    const padX = theme.cellHorizontalPadding;
×
41
    const padY = theme.cellVerticalPadding;
×
42

×
43
    if (fullSize) {
×
44
        return {
×
45
            x: cellRect.x + padX / 2,
×
46
            y: cellRect.y + padY / 2 + 1,
×
47
            width: cellRect.width - padX,
×
48
            height: cellRect.height - padY - 1,
×
49
        };
×
50
    }
×
51

×
52
    const m = measureTextCached(displayData, ctx, theme.baseFontFull, "alphabetic");
×
53
    const maxH = cellRect.height - padY;
×
54
    const h = Math.min(maxH, m.actualBoundingBoxAscent * 2.5);
×
55
    return {
×
56
        x: cellRect.x + padX / 2,
×
57
        y: cellRect.y + (cellRect.height - h) / 2 + 1,
×
58
        width: m.width + padX * 3,
×
59
        height: h - 1,
×
60
    };
×
61
}
×
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