@chronocide/hyper 1.1.2 → 1.2.0
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/dist/hyper.d.ts +3 -2
- package/dist/hyper.js +4 -2
- package/package.json +1 -1
package/dist/hyper.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
type CellOptions<T> = {
|
|
2
|
-
/** If
|
|
2
|
+
/** If null, equal to container width */
|
|
3
3
|
width?: number | ((data: T, i: number, arr: T[]) => number | null) | null;
|
|
4
4
|
/** If true, cells do not fill container width */
|
|
5
5
|
gap?: boolean;
|
|
6
|
-
|
|
6
|
+
/** If null, equal to item height (1:1) */
|
|
7
|
+
height: number | ((data: T, i: number, arr: T[]) => number | null) | null;
|
|
7
8
|
};
|
|
8
9
|
|
|
9
10
|
type Json = string | number | boolean | null | Json[] | {
|
package/dist/hyper.js
CHANGED
|
@@ -72,10 +72,12 @@ const bisectRight = (arr) => (n) => {
|
|
|
72
72
|
|
|
73
73
|
const cells = (cell) => (container) => (data) => fill(data.length)((i, arr) => {
|
|
74
74
|
const prev = get(arr)(i - 1);
|
|
75
|
-
const height2 = typeof cell.height === "number" ? cell.height : cell.height(data[i], i, data);
|
|
76
75
|
let width = container.width;
|
|
77
76
|
if (typeof cell.width === "number") width = cell.width;
|
|
78
77
|
if (typeof cell.width === "function") width = cell.width(data[i], i, data) ?? container.width;
|
|
78
|
+
let height2 = width;
|
|
79
|
+
if (typeof cell.height === "number") height2 = cell.height;
|
|
80
|
+
if (typeof cell.height === "function") height2 = cell.height(data[i], i, data) ?? width;
|
|
79
81
|
if (!cell.gap) {
|
|
80
82
|
const rows = Math.max(1, Math.floor(container.width / width));
|
|
81
83
|
width = Math.floor(container.width / rows);
|
|
@@ -179,7 +181,7 @@ const virtual$1 = (env) => (cell) => (render) => (root) => {
|
|
|
179
181
|
let cache = [];
|
|
180
182
|
let state = [];
|
|
181
183
|
const update = debounce(env)((full) => {
|
|
182
|
-
if (full) cache = cells(cell)({ width: root.
|
|
184
|
+
if (full) cache = cells(cell)({ width: root.clientWidth })(state);
|
|
183
185
|
const [min, max] = view({
|
|
184
186
|
height: root.getBoundingClientRect().height,
|
|
185
187
|
y: Math.floor(root.scrollTop)
|