@yasanchezz/vue-infinite-grid 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -71,7 +71,7 @@ part of the rendered window (see [Styling notes](#styling-notes)).
71
71
  | `rowsCount` | `number` | yes | - | How many rows to render at once (the size of the rendered window). |
72
72
  | `rowInitialHeight` | `number` | yes | - | Estimated row height in px, used for scroll/offset math before a row has actually been measured. |
73
73
  | `container` | `Element \| null \| ((container: Element \| null) => Element \| null \| undefined)` | no | `document.documentElement` | The scrollable element to listen to. Can be a function that receives the grid's root element (useful for resolving a custom scroll container after mount). |
74
- | `autoCalculatedRowsCount` | `boolean` | no | `false` | When `true`, grows the rendered window beyond `rowsCount` based on measured row heights so it always covers the viewport (useful when actual row heights are smaller than the estimated `rowInitialHeight`). |
74
+ | `rowsCountAutoCalculated` | `boolean` | no | `false` | When `true`, grows the rendered window beyond `rowsCount` based on measured row heights so it always covers the viewport (useful when actual row heights are smaller than the estimated `rowInitialHeight`). |
75
75
  | `rowsOffset` | `number` | no | `rowInitialHeight * Math.trunc(rowsCount / 5)` (or `1000` if that's `0`) | Extra px of buffer kept rendered above/below the viewport before the window shifts, to reduce blank space while scrolling fast. |
76
76
 
77
77
  ## Slots
package/dist/VueGrid.d.ts CHANGED
@@ -3,11 +3,11 @@ declare const __VLS_export: <GridRow extends {
3
3
  sticky?: boolean;
4
4
  }>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
5
5
  props: import('vue').PublicProps & __VLS_PrettifyLocal<{
6
- autoCalculatedRowsCount?: boolean;
7
6
  container?: (Element | null | undefined) | ((container: Element | null) => Element | null | undefined);
8
7
  rowInitialHeight: number;
9
8
  rows: GridRow[];
10
9
  rowsCount: number;
10
+ rowsCountAutoCalculated?: boolean;
11
11
  rowsOffset?: number;
12
12
  }> & (typeof globalThis extends {
13
13
  __VLS_PROPS_FALLBACK: infer P;
@@ -1,2 +1,2 @@
1
- @layer VueGrid{.infinite-grid[data-v-145b839c]{overflow-anchor:none;align-content:start;width:max-content;display:grid;overflow:clip}.grid-row[data-v-145b839c]{grid-column:1/-1;grid-template-columns:subgrid;display:grid}.grid-row--sticky[data-v-145b839c]{position:sticky;top:0}.content[data-v-145b839c]{display:contents}.before[data-v-145b839c],.after[data-v-145b839c]{pointer-events:none;grid-column:1/-1}}
1
+ @layer VueGrid{.infinite-grid[data-v-e50d93db]{overflow-anchor:none;align-content:start;width:max-content;display:grid;overflow:clip}.grid-row[data-v-e50d93db]{grid-column:1/-1;grid-template-columns:subgrid;display:grid}.grid-row--sticky[data-v-e50d93db]{position:sticky;top:0}.content[data-v-e50d93db]{display:contents}.before[data-v-e50d93db],.after[data-v-e50d93db]{pointer-events:none;grid-column:1/-1}}
2
2
  /*$vite$:1*/
@@ -7,10 +7,6 @@ var h = ["data-index"], g = /*#__PURE__*/ ((e, t) => {
7
7
  })(/* @__PURE__ */ i({
8
8
  __name: "VueGrid",
9
9
  props: {
10
- autoCalculatedRowsCount: {
11
- type: Boolean,
12
- default: !1
13
- },
14
10
  container: {
15
11
  type: [null, Function],
16
12
  default: null
@@ -18,6 +14,10 @@ var h = ["data-index"], g = /*#__PURE__*/ ((e, t) => {
18
14
  rowInitialHeight: {},
19
15
  rows: {},
20
16
  rowsCount: {},
17
+ rowsCountAutoCalculated: {
18
+ type: Boolean,
19
+ default: !1
20
+ },
21
21
  rowsOffset: { default: 0 }
22
22
  },
23
23
  setup(i, { expose: g }) {
@@ -39,7 +39,7 @@ var h = ["data-index"], g = /*#__PURE__*/ ((e, t) => {
39
39
  }
40
40
  let M = i.rowsCount;
41
41
  function N() {
42
- if (i.autoCalculatedRowsCount) {
42
+ if (i.rowsCountAutoCalculated) {
43
43
  let e = window.innerHeight + i.rowInitialHeight, t = z - C, n = t < e ? Math.ceil(e / t * M) : M;
44
44
  M = Number.isFinite(n) && n >= i.rowsCount ? n : i.rowsCount;
45
45
  }
@@ -78,22 +78,23 @@ var h = ["data-index"], g = /*#__PURE__*/ ((e, t) => {
78
78
  function X() {
79
79
  Y = L - W - z, J.value.height = `${Y}px`;
80
80
  }
81
- function Z() {
82
- cancelAnimationFrame(w), w = requestAnimationFrame(() => {
83
- F(), H(), R(), G(), q(), X();
84
- let e = 0, t = 0, n, r;
85
- for (let [a, o] of i.rows.entries()) {
86
- let i = j(a);
87
- if (e += i, e > W) {
88
- t = a;
89
- break;
90
- }
91
- o.sticky && (n = o, r = a, K = i);
81
+ function ne() {
82
+ F(), H(), R(), G(), q(), X();
83
+ let e = 0, t = 0, n, r;
84
+ for (let [a, o] of i.rows.entries()) {
85
+ let i = j(a);
86
+ if (e += i, e > W) {
87
+ t = a;
88
+ break;
92
89
  }
93
- [B, V] = t + M > i.rows.length || !Y ? [i.rows.length - M, i.rows.length] : [t, t + M];
94
- let a = n && r != null && r < B ? [n] : [], o = a.length, s = i.rows.slice(B, V), c = a.concat(s);
95
- o || (K = 0), (c.at(o) !== _.value.at(o) || c.length !== _.value.length) && (_.value = c), H(), R(), q(), X();
96
- });
90
+ o.sticky && (n = o, r = a, K = i);
91
+ }
92
+ [B, V] = t + M > i.rows.length || !Y ? [i.rows.length - M, i.rows.length] : [t, t + M], B < 0 && (B = 0);
93
+ let a = n && r != null && r < B ? [n] : [], o = a.length, s = i.rows.slice(B, V), c = a.concat(s);
94
+ o || (K = 0), (c.at(o) !== _.value.at(o) || c.length !== _.value.length) && (_.value = c), H(), R(), G(), q(), X();
95
+ }
96
+ function Z() {
97
+ cancelAnimationFrame(w), w = requestAnimationFrame(ne);
97
98
  }
98
99
  let Q = new ResizeObserver((e) => {
99
100
  for (let t of e) {
@@ -142,7 +143,7 @@ var h = ["data-index"], g = /*#__PURE__*/ ((e, t) => {
142
143
  });
143
144
  }
144
145
  });
145
- function ne(e) {
146
+ function re(e) {
146
147
  let t = "grid-row";
147
148
  return {
148
149
  [t]: !0,
@@ -165,7 +166,7 @@ var h = ["data-index"], g = /*#__PURE__*/ ((e, t) => {
165
166
  class: "content"
166
167
  }, [(l(!0), n(e, null, ee(_.value, (e) => (l(), n("div", {
167
168
  key: e.id,
168
- class: a(ne(e)),
169
+ class: a(re(e)),
169
170
  "data-index": e.id
170
171
  }, [te(t.$slots, "row", { row: e }, void 0, !0)], 10, h))), 128))], 512),
171
172
  r("div", {
@@ -174,7 +175,7 @@ var h = ["data-index"], g = /*#__PURE__*/ ((e, t) => {
174
175
  }, null, 4)
175
176
  ], 4));
176
177
  }
177
- }), [["__scopeId", "data-v-145b839c"]]), _ = { install(e) {
178
+ }), [["__scopeId", "data-v-e50d93db"]]), _ = { install(e) {
178
179
  e.component("VueGrid", g);
179
180
  } };
180
181
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yasanchezz/vue-infinite-grid",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"