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

naver / egjs-infinitegrid / 3869242514

pending completion
3869242514

Pull #527

github

GitHub
Merge 42f03d580 into 6db0bffc8
Pull Request #527: feat: upgrade to Angular 15 and enable partial compilation

523 of 649 branches covered (80.59%)

Branch coverage included in aggregate %.

1349 of 1446 relevant lines covered (93.29%)

114.11 hits per line

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

79.59
/packages/infinitegrid/src/LoadingGrid.ts
1
import Grid, { GridItem, GridOutlines } from "@egjs/grid";
1✔
2
import { ITEM_TYPE } from "./consts";
1✔
3
import { InfiniteGridItem, InfiniteGridItemStatus } from "./InfiniteGridItem";
1✔
4

5
export const LOADING_GROUP_KEY = "__INFINITEGRID__LOADING_GRID";
1✔
6
export const LOADING_ITEM_KEY = "__INFINITEGRID__LOADING_ITEM";
1✔
7

8
export class LoadingGrid extends Grid {
67!
9
  public type: "start" | "end" | "" = "";
65✔
10
  public getLoadingItem(): InfiniteGridItem | null {
1✔
11
    return this.items[0] as InfiniteGridItem || null;
376✔
12
  }
13
  public setLoadingItem(item: Partial<InfiniteGridItemStatus> | null) {
1✔
14
    if (item) {
4✔
15
      const loadingItem = this.getLoadingItem();
3✔
16

17
      if (!loadingItem) {
3✔
18
        this.items = [new InfiniteGridItem(this.options.horizontal, {
2✔
19
          ...item,
20
          type: ITEM_TYPE.LOADING,
21
          key: LOADING_ITEM_KEY,
22
        })];
23
      } else {
24
        for (const name in item) {
1✔
25
          loadingItem[name] = item[name];
×
26
        }
27
      }
28
    } else {
29
      this.items = [];
1✔
30
    }
31
  }
32
  public applyGrid(items: GridItem[], direction: "start" | "end", outline: number[]): GridOutlines {
1✔
33
    if (!items.length) {
1!
34
      return {
×
35
        start: outline,
36
        end: outline,
37
      };
38
    }
39
    const nextOutline = outline.length ? [...outline] : [0];
1!
40
    const item = items[0];
1✔
41
    const offset = item.contentSize + this.gap;
1✔
42

43
    item.cssInlinePos = this.getContainerInlineSize() / 2 - item.inlineSize / 2;
1✔
44

45
    if (direction === "end") {
1!
46
      const maxPos = Math.max(...nextOutline);
1✔
47

48
      item.cssContentPos = maxPos;
1✔
49

50
      return {
1✔
51
        start: nextOutline,
52
        end: nextOutline.map((pos) => pos + offset),
1✔
53
      };
54
    } else {
55
      const minPos = Math.min(...nextOutline);
×
56

57
      item.cssContentPos = minPos - offset;
×
58

59
      return {
×
60
        start: nextOutline.map((pos) => pos - offset),
×
61
        end: nextOutline,
62
      };
63
    }
64
  }
65
}
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