@yasanchezz/vue-infinite-grid 0.1.5 → 0.1.7
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/VueGrid.d.ts +1 -1
- package/dist/vue-infinite-grid.css +1 -1
- package/dist/vue-infinite-grid.js +64 -64
- package/package.json +1 -1
package/dist/VueGrid.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ declare const __VLS_export: <GridRow extends {
|
|
|
12
12
|
} ? P : {});
|
|
13
13
|
expose: (exposed: import('vue').ShallowUnwrapRef<{
|
|
14
14
|
init(): void;
|
|
15
|
-
scrollTo(id: string): Element | null
|
|
15
|
+
scrollTo(id: string): Promise<Element | null>;
|
|
16
16
|
}>) => void;
|
|
17
17
|
attrs: any;
|
|
18
18
|
slots: {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
.infinite-grid[data-v-
|
|
1
|
+
.infinite-grid[data-v-581d3de4]{overflow-anchor:none;align-content:start;display:grid;overflow:clip}.grid-row[data-v-581d3de4]{grid-column:1/-1;grid-template-columns:subgrid;display:grid}.content[data-v-581d3de4]{display:contents}.before[data-v-581d3de4],.after[data-v-581d3de4]{pointer-events:none;grid-column:1/-1}
|
|
2
2
|
/*$vite$:1*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Fragment as e, computed as t, createElementBlock as n, createElementVNode as r, defineComponent as i,
|
|
1
|
+
import { Fragment as e, computed as t, createElementBlock as n, createElementVNode as r, defineComponent as i, nextTick as a, normalizeStyle as o, onMounted as s, onUnmounted as c, openBlock as l, ref as u, renderList as d, renderSlot as f, shallowRef as p, useTemplateRef as m, watch as h, watchEffect as g } from "vue";
|
|
2
2
|
//#region src/VueGrid.vue?vue&type=script&setup=true&lang.ts
|
|
3
|
-
var
|
|
3
|
+
var _ = ["data-index"], v = /*#__PURE__*/ ((e, t) => {
|
|
4
4
|
let n = e.__vccOpts || e;
|
|
5
5
|
for (let [e, r] of t) n[e] = r;
|
|
6
6
|
return n;
|
|
@@ -19,119 +19,119 @@ var g = ["data-index"], _ = /*#__PURE__*/ ((e, t) => {
|
|
|
19
19
|
rowsCount: {},
|
|
20
20
|
height: {}
|
|
21
21
|
},
|
|
22
|
-
setup(i, { expose:
|
|
23
|
-
let
|
|
24
|
-
function
|
|
22
|
+
setup(i, { expose: v }) {
|
|
23
|
+
let y = p([]), b = m("grid"), x = m("content"), S = t(() => i.container instanceof Function ? i.container(b.value) ?? document.documentElement : i.container ?? document.documentElement), C = t(() => S.value === document.documentElement || S.value === document.body ? window : S.value), w = /* @__PURE__ */ new Map(), T = i.height * Math.trunc(i.rowsCount / 5) || 1e3, E, D, O = i.rowsCount;
|
|
24
|
+
function k() {
|
|
25
25
|
if (i.autoCalculatedRowsCount) {
|
|
26
|
-
let e = window.innerHeight + i.height, t =
|
|
27
|
-
|
|
26
|
+
let e = window.innerHeight + i.height, t = F - T, n = t < e ? Math.ceil(e / t * O) : O;
|
|
27
|
+
O = n < i.rowsCount ? i.rowsCount : n;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
let
|
|
31
|
-
function
|
|
32
|
-
let e = 0, t =
|
|
33
|
-
for (; t instanceof HTMLElement && t !=
|
|
34
|
-
|
|
30
|
+
let A = 0;
|
|
31
|
+
function j() {
|
|
32
|
+
let e = 0, t = b.value;
|
|
33
|
+
for (; t instanceof HTMLElement && t != S.value;) e += t.offsetTop, t = t.offsetParent;
|
|
34
|
+
A = e;
|
|
35
35
|
}
|
|
36
|
-
let
|
|
37
|
-
function
|
|
38
|
-
return
|
|
36
|
+
let M = u({ height: "0px" }), N = 0;
|
|
37
|
+
function P() {
|
|
38
|
+
return N = i.rows.map((e) => w.get(e.id) ?? i.height).reduce((e, t) => e + t, 0), M.value.height = `${N}px`, N;
|
|
39
39
|
}
|
|
40
|
-
let
|
|
41
|
-
function
|
|
42
|
-
|
|
40
|
+
let F = 0;
|
|
41
|
+
function I() {
|
|
42
|
+
F = y.value.map((e) => w.get(e.id) ?? i.height).reduce((e, t) => e + t, 0);
|
|
43
43
|
}
|
|
44
|
-
let
|
|
45
|
-
function
|
|
46
|
-
let e =
|
|
44
|
+
let L = u({ height: "0px" }), R = 0;
|
|
45
|
+
function z() {
|
|
46
|
+
let e = S.value.scrollTop - T - A, t = 0;
|
|
47
47
|
for (let n of i.rows) {
|
|
48
|
-
let r =
|
|
48
|
+
let r = w.get(n.id) ?? i.height;
|
|
49
49
|
if (t + r > e) break;
|
|
50
50
|
t += r;
|
|
51
51
|
}
|
|
52
|
-
let n =
|
|
53
|
-
return
|
|
54
|
-
}
|
|
55
|
-
let z = l({ height: "0px" }), B = 0;
|
|
56
|
-
function V() {
|
|
57
|
-
B = M - L - P, z.value.height = `${B}px`;
|
|
52
|
+
let n = N - F, r = t > n ? n : t;
|
|
53
|
+
return R = r, L.value.height = `${r}px`, r;
|
|
58
54
|
}
|
|
55
|
+
let B = u({ height: "0px" }), V = 0;
|
|
59
56
|
function H() {
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
V = N - R - F, B.value.height = `${V}px`;
|
|
58
|
+
}
|
|
59
|
+
function U() {
|
|
60
|
+
cancelAnimationFrame(E), E = requestAnimationFrame(() => {
|
|
61
|
+
j(), I(), P(), z(), H();
|
|
62
62
|
let e = 0, t = 0;
|
|
63
63
|
for (let [n, r] of i.rows.entries()) {
|
|
64
|
-
let a =
|
|
65
|
-
if (e += a, !(e <=
|
|
64
|
+
let a = w.get(r.id) ?? i.height;
|
|
65
|
+
if (e += a, !(e <= R)) {
|
|
66
66
|
t = n;
|
|
67
67
|
break;
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
let n = t +
|
|
71
|
-
|
|
70
|
+
let n = t + O > i.rows.length ? i.rows.slice(i.rows.length - O) : i.rows.slice(t, t + O);
|
|
71
|
+
V || (n = i.rows.slice(i.rows.length - O)), (n.at(0) !== y.value.at(0) || n.length !== y.value.length) && (y.value = n), I(), P(), H();
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
|
-
let
|
|
74
|
+
let W = new ResizeObserver((e) => {
|
|
75
75
|
for (let t of e) {
|
|
76
76
|
let e = t.target, n = t.borderBoxSize.at(0)?.blockSize ?? i.height;
|
|
77
77
|
if (e instanceof HTMLElement) {
|
|
78
78
|
let t = e.dataset.index;
|
|
79
|
-
t != null &&
|
|
79
|
+
t != null && w.set(t, n);
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
cancelAnimationFrame(
|
|
83
|
-
|
|
82
|
+
cancelAnimationFrame(D), D = requestAnimationFrame(() => {
|
|
83
|
+
I(), k(), U();
|
|
84
84
|
});
|
|
85
|
-
}),
|
|
86
|
-
for (let t of e) t.addedNodes.values().filter((e) => e instanceof HTMLElement).forEach((e) =>
|
|
85
|
+
}), G = new MutationObserver((e) => {
|
|
86
|
+
for (let t of e) t.addedNodes.values().filter((e) => e instanceof HTMLElement).forEach((e) => W.observe(e)), t.removedNodes.values().filter((e) => e instanceof HTMLElement).forEach((e) => W.unobserve(e));
|
|
87
87
|
});
|
|
88
|
-
return
|
|
89
|
-
|
|
90
|
-
}),
|
|
91
|
-
t?.removeEventListener("scroll",
|
|
92
|
-
}, { immediate: !0 }),
|
|
93
|
-
|
|
94
|
-
}),
|
|
95
|
-
|
|
96
|
-
}),
|
|
88
|
+
return g(() => {
|
|
89
|
+
G.disconnect(), x.value && G.observe(x.value, { childList: !0 });
|
|
90
|
+
}), h(() => i.rows, U, { flush: "post" }), h(C, (e, t) => {
|
|
91
|
+
t?.removeEventListener("scroll", U), e.addEventListener("scroll", U, { passive: !0 });
|
|
92
|
+
}, { immediate: !0 }), s(() => {
|
|
93
|
+
U();
|
|
94
|
+
}), c(() => {
|
|
95
|
+
C.value.removeEventListener("scroll", U);
|
|
96
|
+
}), v({
|
|
97
97
|
init() {
|
|
98
|
-
|
|
98
|
+
I(), k(), U();
|
|
99
99
|
},
|
|
100
|
-
scrollTo(e) {
|
|
100
|
+
async scrollTo(e) {
|
|
101
101
|
let t = 0;
|
|
102
102
|
for (let n of i.rows) {
|
|
103
103
|
if (n.id === e) break;
|
|
104
|
-
t +=
|
|
104
|
+
t += w.get(n.id) ?? i.height;
|
|
105
105
|
}
|
|
106
|
-
return
|
|
106
|
+
return S.value.scrollTo(0, t + A), await a(), S.value.querySelector(`[data-index="${e}"]`);
|
|
107
107
|
}
|
|
108
|
-
}), (t, i) => (
|
|
108
|
+
}), (t, i) => (l(), n("div", {
|
|
109
109
|
ref_key: "grid",
|
|
110
|
-
ref:
|
|
110
|
+
ref: b,
|
|
111
111
|
class: "infinite-grid",
|
|
112
|
-
style:
|
|
112
|
+
style: o(M.value)
|
|
113
113
|
}, [
|
|
114
114
|
r("div", {
|
|
115
115
|
class: "before",
|
|
116
|
-
style:
|
|
116
|
+
style: o(L.value)
|
|
117
117
|
}, null, 4),
|
|
118
118
|
r("div", {
|
|
119
119
|
ref_key: "content",
|
|
120
|
-
ref:
|
|
120
|
+
ref: x,
|
|
121
121
|
class: "content"
|
|
122
|
-
}, [(
|
|
122
|
+
}, [(l(!0), n(e, null, d(y.value, (e) => (l(), n("div", {
|
|
123
123
|
key: e.id,
|
|
124
124
|
class: "grid-row",
|
|
125
125
|
"data-index": e.id
|
|
126
|
-
}, [
|
|
126
|
+
}, [f(t.$slots, "row", { row: e }, void 0, !0)], 8, _))), 128))], 512),
|
|
127
127
|
r("div", {
|
|
128
128
|
class: "after",
|
|
129
|
-
style:
|
|
129
|
+
style: o(B.value)
|
|
130
130
|
}, null, 4)
|
|
131
131
|
], 4));
|
|
132
132
|
}
|
|
133
|
-
}), [["__scopeId", "data-v-
|
|
134
|
-
e.component("VueGrid",
|
|
133
|
+
}), [["__scopeId", "data-v-581d3de4"]]), y = { install(e) {
|
|
134
|
+
e.component("VueGrid", v);
|
|
135
135
|
} };
|
|
136
136
|
//#endregion
|
|
137
|
-
export {
|
|
137
|
+
export { y as default };
|