@wyxos/vibe 1.4.1 → 1.5.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/lib/index.js +524 -433
- package/lib/vibe.css +1 -1
- package/package.json +3 -2
- package/src/App.vue +3 -1
- package/src/Masonry.vue +219 -32
- package/src/calculateLayout.ts +168 -151
- package/src/masonryUtils.ts +18 -5
- package/src/useMasonryScroll.ts +17 -105
- package/src/useMasonryTransitions.ts +14 -7
package/lib/index.js
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
import { nextTick as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const o =
|
|
8
|
-
|
|
1
|
+
import { nextTick as ee, defineComponent as Ne, computed as ae, ref as j, onMounted as $e, onUnmounted as Ae, createElementBlock as re, openBlock as oe, normalizeClass as he, createElementVNode as V, normalizeStyle as We, createVNode as Be, createCommentVNode as ze, TransitionGroup as Fe, withCtx as Oe, Fragment as De, renderList as je, mergeProps as me, unref as Re, renderSlot as _e, toDisplayString as ve } from "vue";
|
|
2
|
+
let se = null;
|
|
3
|
+
function Ce() {
|
|
4
|
+
if (se != null) return se;
|
|
5
|
+
const e = document.createElement("div");
|
|
6
|
+
e.style.visibility = "hidden", e.style.overflow = "scroll", e.style.msOverflowStyle = "scrollbar", e.style.width = "100px", e.style.height = "100px", document.body.appendChild(e);
|
|
7
|
+
const o = document.createElement("div");
|
|
8
|
+
o.style.width = "100%", e.appendChild(o);
|
|
9
|
+
const i = e.offsetWidth - o.offsetWidth;
|
|
10
|
+
return document.body.removeChild(e), se = i, i;
|
|
9
11
|
}
|
|
10
|
-
function
|
|
12
|
+
function qe(e, o, i, s = {}) {
|
|
11
13
|
const {
|
|
12
|
-
gutterX:
|
|
13
|
-
gutterY:
|
|
14
|
-
header:
|
|
15
|
-
footer:
|
|
16
|
-
paddingLeft:
|
|
17
|
-
paddingRight:
|
|
18
|
-
sizes:
|
|
14
|
+
gutterX: m = 0,
|
|
15
|
+
gutterY: v = 0,
|
|
16
|
+
header: n = 0,
|
|
17
|
+
footer: r = 0,
|
|
18
|
+
paddingLeft: y = 0,
|
|
19
|
+
paddingRight: c = 0,
|
|
20
|
+
sizes: f = {
|
|
19
21
|
base: 1,
|
|
20
22
|
sm: 2,
|
|
21
23
|
md: 3,
|
|
@@ -23,295 +25,295 @@ function St(t, a, o, l = {}) {
|
|
|
23
25
|
xl: 5,
|
|
24
26
|
"2xl": 6
|
|
25
27
|
},
|
|
26
|
-
placement:
|
|
27
|
-
} =
|
|
28
|
-
let x = 0,
|
|
28
|
+
placement: d = "masonry"
|
|
29
|
+
} = s;
|
|
30
|
+
let x = 0, w = 0;
|
|
29
31
|
try {
|
|
30
|
-
if (
|
|
31
|
-
const
|
|
32
|
-
x = parseFloat(
|
|
32
|
+
if (o && o.nodeType === 1 && typeof window < "u" && window.getComputedStyle) {
|
|
33
|
+
const b = window.getComputedStyle(o);
|
|
34
|
+
x = parseFloat(b.paddingLeft) || 0, w = parseFloat(b.paddingRight) || 0;
|
|
33
35
|
}
|
|
34
36
|
} catch {
|
|
35
37
|
}
|
|
36
|
-
const W = (
|
|
37
|
-
const
|
|
38
|
-
return Math.round(
|
|
38
|
+
const W = (y || 0) + x, R = (c || 0) + w, T = o.offsetWidth - o.clientWidth, M = T > 0 ? T + 2 : Ce() + 2, N = o.offsetWidth - M - W - R, F = m * (i - 1), H = Math.floor((N - F) / i), k = e.map((b) => {
|
|
39
|
+
const L = b.width, S = b.height;
|
|
40
|
+
return Math.round(H * S / L) + r + n;
|
|
39
41
|
});
|
|
40
|
-
if (
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
43
|
-
const
|
|
44
|
-
let
|
|
45
|
-
const
|
|
46
|
-
let
|
|
47
|
-
for (let
|
|
48
|
-
const
|
|
49
|
-
if (
|
|
50
|
-
|
|
51
|
-
else if (
|
|
42
|
+
if (d === "sequential-balanced") {
|
|
43
|
+
const b = k.length;
|
|
44
|
+
if (b === 0) return [];
|
|
45
|
+
const L = (p, I, A) => p + (I > 0 ? v : 0) + A;
|
|
46
|
+
let S = Math.max(...k), O = k.reduce((p, I) => p + I, 0) + v * Math.max(0, b - 1);
|
|
47
|
+
const Y = (p) => {
|
|
48
|
+
let I = 1, A = 0, _ = 0;
|
|
49
|
+
for (let z = 0; z < b; z++) {
|
|
50
|
+
const q = k[z], D = L(A, _, q);
|
|
51
|
+
if (D <= p)
|
|
52
|
+
A = D, _++;
|
|
53
|
+
else if (I++, A = q, _ = 1, q > p || I > i) return !1;
|
|
52
54
|
}
|
|
53
|
-
return
|
|
55
|
+
return I <= i;
|
|
54
56
|
};
|
|
55
|
-
for (;
|
|
56
|
-
const
|
|
57
|
-
|
|
57
|
+
for (; S < O; ) {
|
|
58
|
+
const p = Math.floor((S + O) / 2);
|
|
59
|
+
Y(p) ? O = p : S = p + 1;
|
|
58
60
|
}
|
|
59
|
-
const
|
|
60
|
-
let
|
|
61
|
-
for (let
|
|
62
|
-
const
|
|
63
|
-
!(
|
|
61
|
+
const J = O, G = new Array(i).fill(0);
|
|
62
|
+
let K = i - 1, U = 0, B = 0;
|
|
63
|
+
for (let p = b - 1; p >= 0; p--) {
|
|
64
|
+
const I = k[p], A = p < K;
|
|
65
|
+
!(L(U, B, I) <= J) || A ? (G[K] = p + 1, K--, U = I, B = 1) : (U = L(U, B, I), B++);
|
|
64
66
|
}
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
for (let
|
|
68
|
-
const
|
|
69
|
-
for (let
|
|
70
|
-
const
|
|
71
|
-
|
|
67
|
+
G[0] = 0;
|
|
68
|
+
const Q = [], X = new Array(i).fill(0);
|
|
69
|
+
for (let p = 0; p < i; p++) {
|
|
70
|
+
const I = G[p], A = p + 1 < i ? G[p + 1] : b, _ = p * (H + m);
|
|
71
|
+
for (let z = I; z < A; z++) {
|
|
72
|
+
const D = {
|
|
73
|
+
...e[z],
|
|
74
|
+
columnWidth: H,
|
|
75
|
+
imageHeight: 0,
|
|
76
|
+
columnHeight: 0,
|
|
77
|
+
left: 0,
|
|
78
|
+
top: 0
|
|
79
|
+
};
|
|
80
|
+
D.imageHeight = k[z] - (r + n), D.columnHeight = k[z], D.left = _, D.top = X[p], X[p] += D.columnHeight + (z + 1 < A ? v : 0), Q.push(D);
|
|
72
81
|
}
|
|
73
82
|
}
|
|
74
|
-
return
|
|
83
|
+
return Q;
|
|
75
84
|
}
|
|
76
|
-
const
|
|
77
|
-
for (let
|
|
78
|
-
const
|
|
79
|
-
|
|
85
|
+
const h = new Array(i).fill(0), $ = [];
|
|
86
|
+
for (let b = 0; b < e.length; b++) {
|
|
87
|
+
const L = e[b], S = {
|
|
88
|
+
...L,
|
|
89
|
+
columnWidth: 0,
|
|
90
|
+
imageHeight: 0,
|
|
91
|
+
columnHeight: 0,
|
|
92
|
+
left: 0,
|
|
93
|
+
top: 0
|
|
94
|
+
}, O = h.indexOf(Math.min(...h)), Y = L.width, J = L.height;
|
|
95
|
+
S.columnWidth = H, S.left = O * (H + m), S.imageHeight = Math.round(H * J / Y), S.columnHeight = S.imageHeight + r + n, S.top = h[O], h[O] += S.columnHeight + v, $.push(S);
|
|
80
96
|
}
|
|
81
|
-
return
|
|
97
|
+
return $;
|
|
82
98
|
}
|
|
83
|
-
var
|
|
84
|
-
function
|
|
85
|
-
var
|
|
99
|
+
var Ve = typeof global == "object" && global && global.Object === Object && global, Ge = typeof self == "object" && self && self.Object === Object && self, Ie = Ve || Ge || Function("return this")(), ie = Ie.Symbol, Pe = Object.prototype, Ue = Pe.hasOwnProperty, Xe = Pe.toString, Z = ie ? ie.toStringTag : void 0;
|
|
100
|
+
function Ye(e) {
|
|
101
|
+
var o = Ue.call(e, Z), i = e[Z];
|
|
86
102
|
try {
|
|
87
|
-
|
|
88
|
-
var
|
|
103
|
+
e[Z] = void 0;
|
|
104
|
+
var s = !0;
|
|
89
105
|
} catch {
|
|
90
106
|
}
|
|
91
|
-
var
|
|
92
|
-
return
|
|
107
|
+
var m = Xe.call(e);
|
|
108
|
+
return s && (o ? e[Z] = i : delete e[Z]), m;
|
|
93
109
|
}
|
|
94
|
-
var
|
|
95
|
-
function
|
|
96
|
-
return
|
|
110
|
+
var Je = Object.prototype, Ke = Je.toString;
|
|
111
|
+
function Qe(e) {
|
|
112
|
+
return Ke.call(e);
|
|
97
113
|
}
|
|
98
|
-
var
|
|
99
|
-
function
|
|
100
|
-
return
|
|
114
|
+
var Ze = "[object Null]", et = "[object Undefined]", be = ie ? ie.toStringTag : void 0;
|
|
115
|
+
function tt(e) {
|
|
116
|
+
return e == null ? e === void 0 ? et : Ze : be && be in Object(e) ? Ye(e) : Qe(e);
|
|
101
117
|
}
|
|
102
|
-
function
|
|
103
|
-
return
|
|
118
|
+
function nt(e) {
|
|
119
|
+
return e != null && typeof e == "object";
|
|
104
120
|
}
|
|
105
|
-
var
|
|
106
|
-
function
|
|
107
|
-
return typeof
|
|
121
|
+
var at = "[object Symbol]";
|
|
122
|
+
function rt(e) {
|
|
123
|
+
return typeof e == "symbol" || nt(e) && tt(e) == at;
|
|
108
124
|
}
|
|
109
|
-
var
|
|
110
|
-
function
|
|
111
|
-
for (var
|
|
125
|
+
var ot = /\s/;
|
|
126
|
+
function it(e) {
|
|
127
|
+
for (var o = e.length; o-- && ot.test(e.charAt(o)); )
|
|
112
128
|
;
|
|
113
|
-
return
|
|
129
|
+
return o;
|
|
114
130
|
}
|
|
115
|
-
var
|
|
116
|
-
function
|
|
117
|
-
return
|
|
131
|
+
var st = /^\s+/;
|
|
132
|
+
function lt(e) {
|
|
133
|
+
return e && e.slice(0, it(e) + 1).replace(st, "");
|
|
118
134
|
}
|
|
119
|
-
function
|
|
120
|
-
var
|
|
121
|
-
return
|
|
135
|
+
function ce(e) {
|
|
136
|
+
var o = typeof e;
|
|
137
|
+
return e != null && (o == "object" || o == "function");
|
|
122
138
|
}
|
|
123
|
-
var
|
|
124
|
-
function
|
|
125
|
-
if (typeof
|
|
126
|
-
return
|
|
127
|
-
if (
|
|
128
|
-
return
|
|
129
|
-
if (
|
|
130
|
-
var
|
|
131
|
-
|
|
139
|
+
var xe = NaN, ct = /^[-+]0x[0-9a-f]+$/i, ut = /^0b[01]+$/i, ft = /^0o[0-7]+$/i, dt = parseInt;
|
|
140
|
+
function we(e) {
|
|
141
|
+
if (typeof e == "number")
|
|
142
|
+
return e;
|
|
143
|
+
if (rt(e))
|
|
144
|
+
return xe;
|
|
145
|
+
if (ce(e)) {
|
|
146
|
+
var o = typeof e.valueOf == "function" ? e.valueOf() : e;
|
|
147
|
+
e = ce(o) ? o + "" : o;
|
|
132
148
|
}
|
|
133
|
-
if (typeof
|
|
134
|
-
return
|
|
135
|
-
|
|
136
|
-
var
|
|
137
|
-
return
|
|
149
|
+
if (typeof e != "string")
|
|
150
|
+
return e === 0 ? e : +e;
|
|
151
|
+
e = lt(e);
|
|
152
|
+
var i = ut.test(e);
|
|
153
|
+
return i || ft.test(e) ? dt(e.slice(2), i ? 2 : 8) : ct.test(e) ? xe : +e;
|
|
138
154
|
}
|
|
139
|
-
var
|
|
140
|
-
return
|
|
141
|
-
},
|
|
142
|
-
function
|
|
143
|
-
var
|
|
144
|
-
if (typeof
|
|
145
|
-
throw new TypeError(
|
|
146
|
-
|
|
147
|
-
function
|
|
148
|
-
var
|
|
149
|
-
return
|
|
155
|
+
var le = function() {
|
|
156
|
+
return Ie.Date.now();
|
|
157
|
+
}, gt = "Expected a function", pt = Math.max, yt = Math.min;
|
|
158
|
+
function Te(e, o, i) {
|
|
159
|
+
var s, m, v, n, r, y, c = 0, f = !1, d = !1, x = !0;
|
|
160
|
+
if (typeof e != "function")
|
|
161
|
+
throw new TypeError(gt);
|
|
162
|
+
o = we(o) || 0, ce(i) && (f = !!i.leading, d = "maxWait" in i, v = d ? pt(we(i.maxWait) || 0, o) : v, x = "trailing" in i ? !!i.trailing : x);
|
|
163
|
+
function w(h) {
|
|
164
|
+
var $ = s, b = m;
|
|
165
|
+
return s = m = void 0, c = h, n = e.apply(b, $), n;
|
|
150
166
|
}
|
|
151
|
-
function W(
|
|
152
|
-
return
|
|
167
|
+
function W(h) {
|
|
168
|
+
return c = h, r = setTimeout(M, o), f ? w(h) : n;
|
|
153
169
|
}
|
|
154
|
-
function
|
|
155
|
-
var
|
|
156
|
-
return
|
|
170
|
+
function R(h) {
|
|
171
|
+
var $ = h - y, b = h - c, L = o - $;
|
|
172
|
+
return d ? yt(L, v - b) : L;
|
|
157
173
|
}
|
|
158
|
-
function
|
|
159
|
-
var
|
|
160
|
-
return
|
|
174
|
+
function T(h) {
|
|
175
|
+
var $ = h - y, b = h - c;
|
|
176
|
+
return y === void 0 || $ >= o || $ < 0 || d && b >= v;
|
|
161
177
|
}
|
|
162
|
-
function
|
|
163
|
-
var
|
|
164
|
-
if (
|
|
165
|
-
return
|
|
166
|
-
|
|
178
|
+
function M() {
|
|
179
|
+
var h = le();
|
|
180
|
+
if (T(h))
|
|
181
|
+
return N(h);
|
|
182
|
+
r = setTimeout(M, R(h));
|
|
167
183
|
}
|
|
168
|
-
function
|
|
169
|
-
return
|
|
184
|
+
function N(h) {
|
|
185
|
+
return r = void 0, x && s ? w(h) : (s = m = void 0, n);
|
|
170
186
|
}
|
|
171
|
-
function
|
|
172
|
-
|
|
187
|
+
function F() {
|
|
188
|
+
r !== void 0 && clearTimeout(r), c = 0, s = y = m = r = void 0;
|
|
173
189
|
}
|
|
174
|
-
function
|
|
175
|
-
return
|
|
190
|
+
function H() {
|
|
191
|
+
return r === void 0 ? n : N(le());
|
|
176
192
|
}
|
|
177
|
-
function
|
|
178
|
-
var
|
|
179
|
-
if (
|
|
180
|
-
if (
|
|
181
|
-
return W(
|
|
182
|
-
if (
|
|
183
|
-
return clearTimeout(
|
|
193
|
+
function k() {
|
|
194
|
+
var h = le(), $ = T(h);
|
|
195
|
+
if (s = arguments, m = this, y = h, $) {
|
|
196
|
+
if (r === void 0)
|
|
197
|
+
return W(y);
|
|
198
|
+
if (d)
|
|
199
|
+
return clearTimeout(r), r = setTimeout(M, o), w(y);
|
|
184
200
|
}
|
|
185
|
-
return
|
|
201
|
+
return r === void 0 && (r = setTimeout(M, o)), n;
|
|
186
202
|
}
|
|
187
|
-
return
|
|
203
|
+
return k.cancel = F, k.flush = H, k;
|
|
188
204
|
}
|
|
189
|
-
function
|
|
190
|
-
const
|
|
191
|
-
return
|
|
205
|
+
function Me(e) {
|
|
206
|
+
const o = window.innerWidth, i = e.sizes;
|
|
207
|
+
return o >= 1536 && i["2xl"] ? i["2xl"] : o >= 1280 && i.xl ? i.xl : o >= 1024 && i.lg ? i.lg : o >= 768 && i.md ? i.md : o >= 640 && i.sm ? i.sm : i.base;
|
|
192
208
|
}
|
|
193
|
-
function
|
|
194
|
-
return
|
|
209
|
+
function ht(e) {
|
|
210
|
+
return e.reduce((i, s) => Math.max(i, s.top + s.columnHeight), 0) + 500;
|
|
195
211
|
}
|
|
196
|
-
function
|
|
212
|
+
function mt(e) {
|
|
197
213
|
return {
|
|
198
|
-
transform: `translate3d(${
|
|
214
|
+
transform: `translate3d(${e.left}px, ${e.top}px, 0)`,
|
|
199
215
|
top: "0px",
|
|
200
216
|
left: "0px",
|
|
201
|
-
width: `${
|
|
202
|
-
height: `${
|
|
217
|
+
width: `${e.columnWidth}px`,
|
|
218
|
+
height: `${e.columnHeight}px`
|
|
203
219
|
};
|
|
204
220
|
}
|
|
205
|
-
function
|
|
221
|
+
function vt(e, o = 0) {
|
|
206
222
|
return {
|
|
207
|
-
style:
|
|
208
|
-
"data-top":
|
|
209
|
-
"data-left":
|
|
210
|
-
"data-id": `${
|
|
211
|
-
"data-index":
|
|
223
|
+
style: mt(e),
|
|
224
|
+
"data-top": e.top,
|
|
225
|
+
"data-left": e.left,
|
|
226
|
+
"data-id": `${e.page}-${e.id}`,
|
|
227
|
+
"data-index": o
|
|
212
228
|
};
|
|
213
229
|
}
|
|
214
|
-
function
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
230
|
+
function ue(e, o) {
|
|
231
|
+
if (!e.length || o <= 0)
|
|
232
|
+
return new Array(Math.max(1, o)).fill(0);
|
|
233
|
+
const s = Array.from(new Set(e.map((n) => n.left))).sort((n, r) => n - r).slice(0, o), m = /* @__PURE__ */ new Map();
|
|
234
|
+
for (let n = 0; n < s.length; n++) m.set(s[n], n);
|
|
235
|
+
const v = new Array(s.length).fill(0);
|
|
236
|
+
for (const n of e) {
|
|
237
|
+
const r = m.get(n.left);
|
|
238
|
+
r != null && (v[r] = Math.max(v[r], n.top + n.columnHeight));
|
|
219
239
|
}
|
|
220
|
-
|
|
240
|
+
for (; v.length < o; ) v.push(0);
|
|
241
|
+
return v;
|
|
221
242
|
}
|
|
222
|
-
function
|
|
223
|
-
function
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
const
|
|
228
|
-
|
|
243
|
+
function bt(e, o) {
|
|
244
|
+
function i(n, r) {
|
|
245
|
+
const y = parseInt(n.dataset.left || "0", 10), c = parseInt(n.dataset.top || "0", 10), f = parseInt(n.dataset.index || "0", 10), d = Math.min(f * 20, 160), x = n.style.getPropertyValue("--masonry-opacity-delay");
|
|
246
|
+
n.style.setProperty("--masonry-opacity-delay", `${d}ms`), requestAnimationFrame(() => {
|
|
247
|
+
n.style.opacity = "1", n.style.transform = `translate3d(${y}px, ${c}px, 0) scale(1)`;
|
|
248
|
+
const w = () => {
|
|
249
|
+
x ? n.style.setProperty("--masonry-opacity-delay", x) : n.style.removeProperty("--masonry-opacity-delay"), n.removeEventListener("transitionend", w), r();
|
|
229
250
|
};
|
|
230
|
-
|
|
251
|
+
n.addEventListener("transitionend", w);
|
|
231
252
|
});
|
|
232
253
|
}
|
|
233
|
-
function
|
|
234
|
-
const
|
|
235
|
-
|
|
254
|
+
function s(n) {
|
|
255
|
+
const r = parseInt(n.dataset.left || "0", 10), y = parseInt(n.dataset.top || "0", 10);
|
|
256
|
+
n.style.opacity = "0", n.style.transform = `translate3d(${r}px, ${y + 10}px, 0) scale(0.985)`;
|
|
236
257
|
}
|
|
237
|
-
function
|
|
238
|
-
const
|
|
239
|
-
|
|
258
|
+
function m(n) {
|
|
259
|
+
const r = parseInt(n.dataset.left || "0", 10), y = parseInt(n.dataset.top || "0", 10);
|
|
260
|
+
n.style.transition = "none", n.style.opacity = "1", n.style.transform = `translate3d(${r}px, ${y}px, 0) scale(1)`, n.style.removeProperty("--masonry-opacity-delay"), requestAnimationFrame(() => {
|
|
261
|
+
n.style.transition = "";
|
|
262
|
+
});
|
|
240
263
|
}
|
|
241
|
-
function
|
|
242
|
-
const
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
264
|
+
function v(n, r) {
|
|
265
|
+
const y = parseInt(n.dataset.left || "0", 10), c = parseInt(n.dataset.top || "0", 10), f = typeof (o == null ? void 0 : o.leaveDurationMs) == "number" ? o.leaveDurationMs : NaN;
|
|
266
|
+
let d = Number.isFinite(f) && f > 0 ? f : NaN;
|
|
267
|
+
if (!Number.isFinite(d)) {
|
|
268
|
+
const M = getComputedStyle(n).getPropertyValue("--masonry-leave-duration") || "", N = parseFloat(M);
|
|
269
|
+
d = Number.isFinite(N) && N > 0 ? N : 200;
|
|
270
|
+
}
|
|
271
|
+
const x = n.style.transitionDuration, w = () => {
|
|
272
|
+
n.removeEventListener("transitionend", W), clearTimeout(R), n.style.transitionDuration = x || "";
|
|
273
|
+
}, W = (T) => {
|
|
274
|
+
(!T || T.target === n) && (w(), r());
|
|
275
|
+
}, R = setTimeout(() => {
|
|
276
|
+
w(), r();
|
|
277
|
+
}, d + 100);
|
|
249
278
|
requestAnimationFrame(() => {
|
|
250
|
-
|
|
279
|
+
n.style.transitionDuration = `${d}ms`, n.style.opacity = "0", n.style.transform = `translate3d(${y}px, ${c + 10}px, 0) scale(0.985)`, n.addEventListener("transitionend", W);
|
|
251
280
|
});
|
|
252
281
|
}
|
|
253
282
|
return {
|
|
254
|
-
onEnter:
|
|
255
|
-
onBeforeEnter:
|
|
256
|
-
onBeforeLeave:
|
|
257
|
-
onLeave:
|
|
283
|
+
onEnter: i,
|
|
284
|
+
onBeforeEnter: s,
|
|
285
|
+
onBeforeLeave: m,
|
|
286
|
+
onLeave: v
|
|
258
287
|
};
|
|
259
288
|
}
|
|
260
|
-
function
|
|
261
|
-
container:
|
|
262
|
-
masonry:
|
|
263
|
-
columns:
|
|
264
|
-
containerHeight:
|
|
265
|
-
isLoading:
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
leaveEstimateMs: h
|
|
289
|
+
function xt({
|
|
290
|
+
container: e,
|
|
291
|
+
masonry: o,
|
|
292
|
+
columns: i,
|
|
293
|
+
containerHeight: s,
|
|
294
|
+
isLoading: m,
|
|
295
|
+
pageSize: v,
|
|
296
|
+
refreshLayout: n,
|
|
297
|
+
setItemsRaw: r,
|
|
298
|
+
loadNext: y,
|
|
299
|
+
loadThresholdPx: c
|
|
272
300
|
}) {
|
|
273
|
-
let
|
|
274
|
-
async function
|
|
275
|
-
if (!
|
|
276
|
-
const
|
|
277
|
-
|
|
278
|
-
const
|
|
279
|
-
if (
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
console.error("Error in scroll handler:", u);
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
async function W(M) {
|
|
287
|
-
if (!a.value.length || a.value.length <= d) return;
|
|
288
|
-
const T = a.value.reduce((s, v) => {
|
|
289
|
-
const u = v.page;
|
|
290
|
-
return s[u] || (s[u] = []), s[u].push(v), s;
|
|
291
|
-
}, {}), L = Object.keys(T).sort((s, v) => parseInt(s) - parseInt(v));
|
|
292
|
-
if (L.length === 0) return;
|
|
293
|
-
let $ = 0;
|
|
294
|
-
const I = [];
|
|
295
|
-
for (const s of L)
|
|
296
|
-
if (I.push(s), $ += T[s].length, $ >= d) break;
|
|
297
|
-
const p = a.value.filter((s) => !I.includes(String(s.page)));
|
|
298
|
-
p.length !== a.value.length && (g = !0, w(p), await X(), await new Promise((s) => requestAnimationFrame(() => s())), i(p), await X(), await O(), g = !1);
|
|
299
|
-
}
|
|
300
|
-
async function O() {
|
|
301
|
-
if (!t.value) return;
|
|
302
|
-
const { scrollTop: M, clientHeight: T } = t.value, L = M + T * 0.4, $ = tt(a.value, o.value), I = $.indexOf(Math.max(...$)), p = a.value.filter((u, k) => k % o.value === I);
|
|
303
|
-
if (p.length === 0) return;
|
|
304
|
-
let s = p[0];
|
|
305
|
-
for (const u of p)
|
|
306
|
-
u.top <= L && u.top >= s.top && (s = u);
|
|
307
|
-
const v = Math.max(0, s.top - T * 0.4);
|
|
308
|
-
Math.abs(v - M) > 4 && t.value.scrollTo({ top: v, behavior: "auto" });
|
|
301
|
+
let f = 0;
|
|
302
|
+
async function d(x) {
|
|
303
|
+
if (!e.value) return;
|
|
304
|
+
const w = x ?? ue(o.value, i.value), W = w.length ? Math.max(...w) : 0, R = e.value.scrollTop + e.value.clientHeight, T = e.value.scrollTop > f + 1;
|
|
305
|
+
f = e.value.scrollTop;
|
|
306
|
+
const M = typeof c == "number" ? c : 200, N = M >= 0 ? Math.max(0, W - M) : Math.max(0, W + M);
|
|
307
|
+
if (R >= N && T && !m.value) {
|
|
308
|
+
await y(), await ee();
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
309
311
|
}
|
|
310
312
|
return {
|
|
311
|
-
handleScroll:
|
|
313
|
+
handleScroll: d
|
|
312
314
|
};
|
|
313
315
|
}
|
|
314
|
-
const
|
|
316
|
+
const wt = ["src"], Tt = ["onClick"], Mt = /* @__PURE__ */ Ne({
|
|
315
317
|
__name: "Masonry",
|
|
316
318
|
props: {
|
|
317
319
|
getNextPage: {
|
|
@@ -334,16 +336,12 @@ const ne = ["src"], ae = ["onClick"], re = /* @__PURE__ */ gt({
|
|
|
334
336
|
type: String,
|
|
335
337
|
default: "page",
|
|
336
338
|
// or 'cursor'
|
|
337
|
-
validator: (
|
|
339
|
+
validator: (e) => ["page", "cursor"].includes(e)
|
|
338
340
|
},
|
|
339
341
|
skipInitialLoad: {
|
|
340
342
|
type: Boolean,
|
|
341
343
|
default: !1
|
|
342
344
|
},
|
|
343
|
-
maxItems: {
|
|
344
|
-
type: Number,
|
|
345
|
-
default: 100
|
|
346
|
-
},
|
|
347
345
|
pageSize: {
|
|
348
346
|
type: Number,
|
|
349
347
|
default: 40
|
|
@@ -391,6 +389,14 @@ const ne = ["src"], ae = ["onClick"], re = /* @__PURE__ */ gt({
|
|
|
391
389
|
forceMotion: {
|
|
392
390
|
type: Boolean,
|
|
393
391
|
default: !1
|
|
392
|
+
},
|
|
393
|
+
virtualBufferPx: {
|
|
394
|
+
type: Number,
|
|
395
|
+
default: 600
|
|
396
|
+
},
|
|
397
|
+
loadThresholdPx: {
|
|
398
|
+
type: Number,
|
|
399
|
+
default: 200
|
|
394
400
|
}
|
|
395
401
|
},
|
|
396
402
|
emits: [
|
|
@@ -400,10 +406,11 @@ const ne = ["src"], ae = ["onClick"], re = /* @__PURE__ */ gt({
|
|
|
400
406
|
"backfill:stop",
|
|
401
407
|
"retry:start",
|
|
402
408
|
"retry:tick",
|
|
403
|
-
"retry:stop"
|
|
409
|
+
"retry:stop",
|
|
410
|
+
"remove-all:complete"
|
|
404
411
|
],
|
|
405
|
-
setup(
|
|
406
|
-
const
|
|
412
|
+
setup(e, { expose: o, emit: i }) {
|
|
413
|
+
const s = e, m = {
|
|
407
414
|
sizes: { base: 1, sm: 2, md: 3, lg: 4, xl: 5, "2xl": 6 },
|
|
408
415
|
gutterX: 10,
|
|
409
416
|
gutterY: 10,
|
|
@@ -412,273 +419,357 @@ const ne = ["src"], ae = ["onClick"], re = /* @__PURE__ */ gt({
|
|
|
412
419
|
paddingLeft: 0,
|
|
413
420
|
paddingRight: 0,
|
|
414
421
|
placement: "masonry"
|
|
415
|
-
},
|
|
416
|
-
var
|
|
422
|
+
}, v = ae(() => {
|
|
423
|
+
var t;
|
|
417
424
|
return {
|
|
418
|
-
...
|
|
419
|
-
...
|
|
425
|
+
...m,
|
|
426
|
+
...s.layout,
|
|
420
427
|
sizes: {
|
|
421
|
-
...
|
|
422
|
-
...((
|
|
428
|
+
...m.sizes,
|
|
429
|
+
...((t = s.layout) == null ? void 0 : t.sizes) || {}
|
|
423
430
|
}
|
|
424
431
|
};
|
|
425
|
-
}),
|
|
426
|
-
get: () =>
|
|
427
|
-
set: (
|
|
428
|
-
}),
|
|
429
|
-
|
|
430
|
-
|
|
432
|
+
}), n = i, r = ae({
|
|
433
|
+
get: () => s.items,
|
|
434
|
+
set: (t) => n("update:items", t)
|
|
435
|
+
}), y = j(7), c = j(null), f = j([]), d = j(!1), x = j(0), w = j(/* @__PURE__ */ new Set());
|
|
436
|
+
function W(t) {
|
|
437
|
+
return typeof t == "number" && Number.isFinite(t) && t > 0;
|
|
438
|
+
}
|
|
439
|
+
function R(t, a) {
|
|
440
|
+
try {
|
|
441
|
+
if (!Array.isArray(t) || t.length === 0) return;
|
|
442
|
+
const l = t.filter((g) => !W(g == null ? void 0 : g.width) || !W(g == null ? void 0 : g.height));
|
|
443
|
+
if (l.length === 0) return;
|
|
444
|
+
const u = [];
|
|
445
|
+
for (const g of l) {
|
|
446
|
+
const P = (g == null ? void 0 : g.id) ?? `idx:${t.indexOf(g)}`;
|
|
447
|
+
w.value.has(P) || (w.value.add(P), u.push(P));
|
|
448
|
+
}
|
|
449
|
+
if (u.length > 0) {
|
|
450
|
+
const g = u.slice(0, 10);
|
|
451
|
+
console.warn(
|
|
452
|
+
"[Masonry] Items missing width/height detected:",
|
|
453
|
+
{
|
|
454
|
+
context: a,
|
|
455
|
+
count: u.length,
|
|
456
|
+
sampleIds: g,
|
|
457
|
+
hint: "Ensure each item has positive width and height. Consider providing fallbacks (e.g., 512x512) at the data layer."
|
|
458
|
+
}
|
|
459
|
+
);
|
|
460
|
+
}
|
|
461
|
+
} catch {
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
const T = j(0), M = j(0), N = s.virtualBufferPx, F = j(!1), H = j({
|
|
431
465
|
distanceToTrigger: 0,
|
|
432
466
|
isNearTrigger: !1
|
|
433
|
-
}),
|
|
434
|
-
if (!
|
|
435
|
-
const { scrollTop:
|
|
436
|
-
|
|
437
|
-
distanceToTrigger: Math.round(
|
|
438
|
-
isNearTrigger:
|
|
467
|
+
}), k = (t) => {
|
|
468
|
+
if (!c.value) return;
|
|
469
|
+
const { scrollTop: a, clientHeight: l } = c.value, u = a + l, g = t ?? ue(r.value, y.value), P = g.length ? Math.max(...g) : 0, C = typeof s.loadThresholdPx == "number" ? s.loadThresholdPx : 200, ne = C >= 0 ? Math.max(0, P - C) : Math.max(0, P + C), ye = Math.max(0, ne - u), Ee = ye <= 100;
|
|
470
|
+
H.value = {
|
|
471
|
+
distanceToTrigger: Math.round(ye),
|
|
472
|
+
isNearTrigger: Ee
|
|
439
473
|
};
|
|
440
|
-
}, { onEnter:
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
474
|
+
}, { onEnter: h, onBeforeEnter: $, onBeforeLeave: b, onLeave: L } = bt(r, { leaveDurationMs: s.leaveDurationMs });
|
|
475
|
+
function S(t, a) {
|
|
476
|
+
if (F.value) {
|
|
477
|
+
const l = parseInt(t.dataset.left || "0", 10), u = parseInt(t.dataset.top || "0", 10);
|
|
478
|
+
t.style.transition = "none", t.style.opacity = "1", t.style.transform = `translate3d(${l}px, ${u}px, 0) scale(1)`, t.style.removeProperty("--masonry-opacity-delay"), requestAnimationFrame(() => {
|
|
479
|
+
t.style.transition = "", a();
|
|
480
|
+
});
|
|
481
|
+
} else
|
|
482
|
+
h(t, a);
|
|
483
|
+
}
|
|
484
|
+
function O(t) {
|
|
485
|
+
if (F.value) {
|
|
486
|
+
const a = parseInt(t.dataset.left || "0", 10), l = parseInt(t.dataset.top || "0", 10);
|
|
487
|
+
t.style.transition = "none", t.style.opacity = "1", t.style.transform = `translate3d(${a}px, ${l}px, 0) scale(1)`, t.style.removeProperty("--masonry-opacity-delay");
|
|
488
|
+
} else
|
|
489
|
+
$(t);
|
|
490
|
+
}
|
|
491
|
+
function Y(t) {
|
|
492
|
+
F.value || b(t);
|
|
493
|
+
}
|
|
494
|
+
function J(t, a) {
|
|
495
|
+
F.value ? a() : L(t, a);
|
|
496
|
+
}
|
|
497
|
+
const G = ae(() => {
|
|
498
|
+
const t = T.value - N, a = T.value + M.value + N, l = r.value;
|
|
499
|
+
return !l || l.length === 0 ? [] : l.filter((u) => {
|
|
500
|
+
const g = u.top;
|
|
501
|
+
return u.top + u.columnHeight >= t && g <= a;
|
|
502
|
+
});
|
|
503
|
+
}), { handleScroll: K } = xt({
|
|
504
|
+
container: c,
|
|
505
|
+
masonry: r,
|
|
506
|
+
columns: y,
|
|
444
507
|
containerHeight: x,
|
|
445
|
-
isLoading:
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
i.value = e;
|
|
508
|
+
isLoading: d,
|
|
509
|
+
pageSize: s.pageSize,
|
|
510
|
+
refreshLayout: B,
|
|
511
|
+
setItemsRaw: (t) => {
|
|
512
|
+
r.value = t;
|
|
451
513
|
},
|
|
452
|
-
loadNext:
|
|
453
|
-
|
|
514
|
+
loadNext: A,
|
|
515
|
+
loadThresholdPx: s.loadThresholdPx
|
|
454
516
|
});
|
|
455
|
-
|
|
456
|
-
isLoading:
|
|
457
|
-
refreshLayout:
|
|
517
|
+
o({
|
|
518
|
+
isLoading: d,
|
|
519
|
+
refreshLayout: B,
|
|
458
520
|
containerHeight: x,
|
|
459
|
-
remove:
|
|
460
|
-
removeMany:
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
521
|
+
remove: _,
|
|
522
|
+
removeMany: z,
|
|
523
|
+
removeAll: D,
|
|
524
|
+
loadNext: A,
|
|
525
|
+
loadPage: I,
|
|
526
|
+
reset: He,
|
|
527
|
+
init: Le,
|
|
528
|
+
paginationHistory: f,
|
|
529
|
+
cancelLoad: de,
|
|
530
|
+
scrollToTop: q,
|
|
531
|
+
totalItems: ae(() => r.value.length)
|
|
466
532
|
});
|
|
467
|
-
function
|
|
468
|
-
const
|
|
469
|
-
let
|
|
470
|
-
if (
|
|
471
|
-
const { scrollTop:
|
|
472
|
-
|
|
533
|
+
function U(t) {
|
|
534
|
+
const a = ht(t);
|
|
535
|
+
let l = 0;
|
|
536
|
+
if (c.value) {
|
|
537
|
+
const { scrollTop: u, clientHeight: g } = c.value;
|
|
538
|
+
l = u + g + 100;
|
|
473
539
|
}
|
|
474
|
-
x.value = Math.max(
|
|
540
|
+
x.value = Math.max(a, l);
|
|
475
541
|
}
|
|
476
|
-
function
|
|
477
|
-
if (!
|
|
478
|
-
|
|
479
|
-
|
|
542
|
+
function B(t) {
|
|
543
|
+
if (!c.value) return;
|
|
544
|
+
R(t, "refreshLayout");
|
|
545
|
+
const a = qe(t, c.value, y.value, v.value);
|
|
546
|
+
U(a), r.value = a;
|
|
480
547
|
}
|
|
481
|
-
function
|
|
482
|
-
return new Promise((
|
|
483
|
-
const
|
|
484
|
-
|
|
548
|
+
function Q(t, a) {
|
|
549
|
+
return new Promise((l) => {
|
|
550
|
+
const u = Math.max(0, t | 0), g = Date.now();
|
|
551
|
+
a(u, u);
|
|
485
552
|
const P = setInterval(() => {
|
|
486
|
-
|
|
487
|
-
|
|
553
|
+
if (E.value) {
|
|
554
|
+
clearInterval(P), l();
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
const C = Date.now() - g, ne = Math.max(0, u - C);
|
|
558
|
+
a(ne, u), ne <= 0 && (clearInterval(P), l());
|
|
488
559
|
}, 100);
|
|
489
560
|
});
|
|
490
561
|
}
|
|
491
|
-
async function
|
|
562
|
+
async function X(t) {
|
|
492
563
|
try {
|
|
493
|
-
const
|
|
494
|
-
return
|
|
495
|
-
} catch (
|
|
496
|
-
throw console.error("Error in getContent:",
|
|
564
|
+
const a = await p(() => s.getNextPage(t));
|
|
565
|
+
return B([...r.value, ...a.items]), a;
|
|
566
|
+
} catch (a) {
|
|
567
|
+
throw console.error("Error in getContent:", a), a;
|
|
497
568
|
}
|
|
498
569
|
}
|
|
499
|
-
async function
|
|
500
|
-
let
|
|
501
|
-
const
|
|
502
|
-
let
|
|
570
|
+
async function p(t) {
|
|
571
|
+
let a = 0;
|
|
572
|
+
const l = s.retryMaxAttempts;
|
|
573
|
+
let u = s.retryInitialDelayMs;
|
|
503
574
|
for (; ; )
|
|
504
575
|
try {
|
|
505
|
-
const
|
|
506
|
-
return
|
|
507
|
-
} catch (
|
|
508
|
-
if (
|
|
509
|
-
throw
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
}),
|
|
576
|
+
const g = await t();
|
|
577
|
+
return a > 0 && n("retry:stop", { attempt: a, success: !0 }), g;
|
|
578
|
+
} catch (g) {
|
|
579
|
+
if (a++, a > l)
|
|
580
|
+
throw n("retry:stop", { attempt: a - 1, success: !1 }), g;
|
|
581
|
+
n("retry:start", { attempt: a, max: l, totalMs: u }), await Q(u, (P, C) => {
|
|
582
|
+
n("retry:tick", { attempt: a, remainingMs: P, totalMs: C });
|
|
583
|
+
}), u += s.retryBackoffStepMs;
|
|
513
584
|
}
|
|
514
585
|
}
|
|
515
|
-
async function
|
|
516
|
-
if (!
|
|
517
|
-
|
|
586
|
+
async function I(t) {
|
|
587
|
+
if (!(d.value || E.value)) {
|
|
588
|
+
d.value = !0, E.value = !1;
|
|
518
589
|
try {
|
|
519
|
-
const
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
590
|
+
const a = r.value.length;
|
|
591
|
+
if (E.value) return;
|
|
592
|
+
const l = await X(t);
|
|
593
|
+
return E.value ? void 0 : (f.value.push(l.nextPage), await fe(a), l);
|
|
594
|
+
} catch (a) {
|
|
595
|
+
throw console.error("Error loading page:", a), a;
|
|
523
596
|
} finally {
|
|
524
|
-
|
|
597
|
+
d.value = !1;
|
|
525
598
|
}
|
|
526
599
|
}
|
|
527
600
|
}
|
|
528
|
-
async function
|
|
529
|
-
if (!
|
|
530
|
-
|
|
601
|
+
async function A() {
|
|
602
|
+
if (!(d.value || E.value)) {
|
|
603
|
+
d.value = !0, E.value = !1;
|
|
531
604
|
try {
|
|
532
|
-
const
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
605
|
+
const t = r.value.length;
|
|
606
|
+
if (E.value) return;
|
|
607
|
+
const a = f.value[f.value.length - 1], l = await X(a);
|
|
608
|
+
return E.value ? void 0 : (f.value.push(l.nextPage), await fe(t), l);
|
|
609
|
+
} catch (t) {
|
|
610
|
+
throw console.error("Error loading next page:", t), t;
|
|
536
611
|
} finally {
|
|
537
|
-
|
|
612
|
+
d.value = !1;
|
|
538
613
|
}
|
|
539
614
|
}
|
|
540
615
|
}
|
|
541
|
-
async function
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
p(n);
|
|
616
|
+
async function _(t) {
|
|
617
|
+
const a = r.value.filter((l) => l.id !== t.id);
|
|
618
|
+
r.value = a, await ee(), await new Promise((l) => requestAnimationFrame(() => l())), requestAnimationFrame(() => {
|
|
619
|
+
B(a);
|
|
546
620
|
});
|
|
547
621
|
}
|
|
548
|
-
async function
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
p(c);
|
|
622
|
+
async function z(t) {
|
|
623
|
+
if (!t || t.length === 0) return;
|
|
624
|
+
const a = new Set(t.map((u) => u.id)), l = r.value.filter((u) => !a.has(u.id));
|
|
625
|
+
r.value = l, await ee(), await new Promise((u) => requestAnimationFrame(() => u())), requestAnimationFrame(() => {
|
|
626
|
+
B(l);
|
|
554
627
|
});
|
|
555
628
|
}
|
|
556
|
-
function
|
|
557
|
-
|
|
629
|
+
function q(t) {
|
|
630
|
+
c.value && c.value.scrollTo({
|
|
631
|
+
top: 0,
|
|
632
|
+
behavior: (t == null ? void 0 : t.behavior) ?? "smooth",
|
|
633
|
+
...t
|
|
634
|
+
});
|
|
558
635
|
}
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
636
|
+
async function D() {
|
|
637
|
+
q({ behavior: "smooth" }), r.value = [], x.value = 0, await ee(), n("remove-all:complete");
|
|
638
|
+
}
|
|
639
|
+
function ke() {
|
|
640
|
+
y.value = Me(v.value), B(r.value), c.value && (T.value = c.value.scrollTop, M.value = c.value.clientHeight);
|
|
641
|
+
}
|
|
642
|
+
let te = !1;
|
|
643
|
+
const E = j(!1);
|
|
644
|
+
async function fe(t) {
|
|
645
|
+
if (!s.backfillEnabled || te || E.value) return;
|
|
646
|
+
const a = (t || 0) + (s.pageSize || 0);
|
|
647
|
+
if (!(!s.pageSize || s.pageSize <= 0 || f.value[f.value.length - 1] == null) && !(r.value.length >= a)) {
|
|
648
|
+
te = !0;
|
|
565
649
|
try {
|
|
566
|
-
let
|
|
567
|
-
for (
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
totalMs: S
|
|
575
|
-
});
|
|
650
|
+
let u = 0;
|
|
651
|
+
for (n("backfill:start", { target: a, fetched: r.value.length, calls: u }); r.value.length < a && u < s.backfillMaxCalls && f.value[f.value.length - 1] != null && !E.value && (await Q(s.backfillDelayMs, (P, C) => {
|
|
652
|
+
n("backfill:tick", {
|
|
653
|
+
fetched: r.value.length,
|
|
654
|
+
target: a,
|
|
655
|
+
calls: u,
|
|
656
|
+
remainingMs: P,
|
|
657
|
+
totalMs: C
|
|
576
658
|
});
|
|
577
|
-
|
|
659
|
+
}), !E.value); ) {
|
|
660
|
+
const g = f.value[f.value.length - 1];
|
|
578
661
|
try {
|
|
579
|
-
|
|
580
|
-
const P = await
|
|
581
|
-
|
|
662
|
+
d.value = !0;
|
|
663
|
+
const P = await X(g);
|
|
664
|
+
if (E.value) break;
|
|
665
|
+
f.value.push(P.nextPage);
|
|
582
666
|
} finally {
|
|
583
|
-
|
|
667
|
+
d.value = !1;
|
|
584
668
|
}
|
|
585
|
-
|
|
669
|
+
u++;
|
|
586
670
|
}
|
|
587
|
-
|
|
671
|
+
n("backfill:stop", { fetched: r.value.length, calls: u });
|
|
588
672
|
} finally {
|
|
589
|
-
|
|
673
|
+
te = !1;
|
|
590
674
|
}
|
|
591
675
|
}
|
|
592
676
|
}
|
|
593
|
-
function
|
|
594
|
-
|
|
677
|
+
function de() {
|
|
678
|
+
E.value = !0, d.value = !1, te = !1;
|
|
679
|
+
}
|
|
680
|
+
function He() {
|
|
681
|
+
de(), c.value && c.value.scrollTo({
|
|
595
682
|
top: 0,
|
|
596
683
|
behavior: "smooth"
|
|
597
|
-
}),
|
|
684
|
+
}), r.value = [], x.value = 0, f.value = [s.loadAtPage], H.value = {
|
|
598
685
|
distanceToTrigger: 0,
|
|
599
686
|
isNearTrigger: !1
|
|
600
687
|
};
|
|
601
688
|
}
|
|
602
|
-
const
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
689
|
+
const ge = Te(async () => {
|
|
690
|
+
c.value && (T.value = c.value.scrollTop, M.value = c.value.clientHeight), F.value = !0, await ee(), await new Promise((a) => requestAnimationFrame(() => a())), F.value = !1;
|
|
691
|
+
const t = ue(r.value, y.value);
|
|
692
|
+
K(t), k(t);
|
|
693
|
+
}, 200), pe = Te(ke, 200);
|
|
694
|
+
function Le(t, a, l) {
|
|
695
|
+
f.value = [a], f.value.push(l), R(t, "init"), B([...r.value, ...t]), k();
|
|
607
696
|
}
|
|
608
|
-
return
|
|
609
|
-
var
|
|
697
|
+
return $e(async () => {
|
|
698
|
+
var t;
|
|
610
699
|
try {
|
|
611
|
-
|
|
612
|
-
const
|
|
613
|
-
|
|
614
|
-
} catch (
|
|
615
|
-
console.error("Error during component initialization:",
|
|
700
|
+
y.value = Me(v.value), c.value && (T.value = c.value.scrollTop, M.value = c.value.clientHeight);
|
|
701
|
+
const a = s.loadAtPage;
|
|
702
|
+
f.value = [a], s.skipInitialLoad || await I(f.value[0]), k();
|
|
703
|
+
} catch (a) {
|
|
704
|
+
console.error("Error during component initialization:", a), d.value = !1;
|
|
616
705
|
}
|
|
617
|
-
(
|
|
618
|
-
}),
|
|
619
|
-
var
|
|
620
|
-
(
|
|
621
|
-
}), (
|
|
622
|
-
class:
|
|
706
|
+
(t = c.value) == null || t.addEventListener("scroll", ge, { passive: !0 }), window.addEventListener("resize", pe);
|
|
707
|
+
}), Ae(() => {
|
|
708
|
+
var t;
|
|
709
|
+
(t = c.value) == null || t.removeEventListener("scroll", ge), window.removeEventListener("resize", pe);
|
|
710
|
+
}), (t, a) => (oe(), re("div", {
|
|
711
|
+
class: he(["overflow-auto w-full flex-1 masonry-container", { "force-motion": s.forceMotion }]),
|
|
623
712
|
ref_key: "container",
|
|
624
|
-
ref:
|
|
713
|
+
ref: c
|
|
625
714
|
}, [
|
|
626
|
-
|
|
715
|
+
V("div", {
|
|
627
716
|
class: "relative",
|
|
628
|
-
style:
|
|
717
|
+
style: We({ height: `${x.value}px`, "--masonry-duration": `${e.transitionDurationMs}ms`, "--masonry-leave-duration": `${e.leaveDurationMs}ms`, "--masonry-ease": e.transitionEasing })
|
|
629
718
|
}, [
|
|
630
|
-
|
|
719
|
+
Be(Fe, {
|
|
631
720
|
name: "masonry",
|
|
632
721
|
css: !1,
|
|
633
|
-
onEnter:
|
|
634
|
-
onBeforeEnter:
|
|
635
|
-
onLeave:
|
|
636
|
-
onBeforeLeave:
|
|
722
|
+
onEnter: S,
|
|
723
|
+
onBeforeEnter: O,
|
|
724
|
+
onLeave: J,
|
|
725
|
+
onBeforeLeave: Y
|
|
637
726
|
}, {
|
|
638
|
-
default:
|
|
639
|
-
(
|
|
640
|
-
key: `${
|
|
727
|
+
default: Oe(() => [
|
|
728
|
+
(oe(!0), re(De, null, je(G.value, (l, u) => (oe(), re("div", me({
|
|
729
|
+
key: `${l.page}-${l.id}`,
|
|
641
730
|
class: "absolute masonry-item",
|
|
642
731
|
ref_for: !0
|
|
643
|
-
},
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
src:
|
|
647
|
-
class: "w-full"
|
|
648
|
-
|
|
649
|
-
|
|
732
|
+
}, Re(vt)(l, u)), [
|
|
733
|
+
_e(t.$slots, "item", me({ ref_for: !0 }, { item: l, remove: _ }), () => [
|
|
734
|
+
V("img", {
|
|
735
|
+
src: l.src,
|
|
736
|
+
class: "w-full",
|
|
737
|
+
loading: "lazy",
|
|
738
|
+
decoding: "async"
|
|
739
|
+
}, null, 8, wt),
|
|
740
|
+
V("button", {
|
|
650
741
|
class: "absolute bottom-0 right-0 bg-red-500 text-white p-2 rounded cursor-pointer",
|
|
651
|
-
onClick: (
|
|
652
|
-
},
|
|
653
|
-
|
|
654
|
-
]), 8,
|
|
742
|
+
onClick: (g) => _(l)
|
|
743
|
+
}, a[0] || (a[0] = [
|
|
744
|
+
V("i", { class: "fas fa-trash" }, null, -1)
|
|
745
|
+
]), 8, Tt)
|
|
655
746
|
], !0)
|
|
656
747
|
], 16))), 128))
|
|
657
748
|
]),
|
|
658
749
|
_: 3
|
|
659
|
-
}
|
|
660
|
-
x.value > 0 ? (
|
|
750
|
+
}),
|
|
751
|
+
x.value > 0 ? (oe(), re("div", {
|
|
661
752
|
key: 0,
|
|
662
|
-
class:
|
|
753
|
+
class: he(["fixed bottom-4 right-4 bg-gray-800 text-white text-xs rounded-full px-3 py-1.5 shadow-lg z-10 transition-opacity duration-300", { "opacity-50 hover:opacity-100": !H.value.isNearTrigger, "opacity-100": H.value.isNearTrigger }])
|
|
663
754
|
}, [
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
], 2)) :
|
|
755
|
+
V("span", null, ve(r.value.length) + " items", 1),
|
|
756
|
+
a[1] || (a[1] = V("span", { class: "mx-2" }, "|", -1)),
|
|
757
|
+
V("span", null, ve(H.value.distanceToTrigger) + "px to load", 1)
|
|
758
|
+
], 2)) : ze("", !0)
|
|
668
759
|
], 4)
|
|
669
760
|
], 2));
|
|
670
761
|
}
|
|
671
|
-
}),
|
|
672
|
-
const
|
|
673
|
-
for (const [
|
|
674
|
-
|
|
675
|
-
return
|
|
676
|
-
},
|
|
677
|
-
install(
|
|
678
|
-
|
|
762
|
+
}), St = (e, o) => {
|
|
763
|
+
const i = e.__vccOpts || e;
|
|
764
|
+
for (const [s, m] of o)
|
|
765
|
+
i[s] = m;
|
|
766
|
+
return i;
|
|
767
|
+
}, Se = /* @__PURE__ */ St(Mt, [["__scopeId", "data-v-b855ca99"]]), Pt = {
|
|
768
|
+
install(e) {
|
|
769
|
+
e.component("WyxosMasonry", Se), e.component("WMasonry", Se);
|
|
679
770
|
}
|
|
680
771
|
};
|
|
681
772
|
export {
|
|
682
|
-
|
|
683
|
-
|
|
773
|
+
Se as Masonry,
|
|
774
|
+
Pt as default
|
|
684
775
|
};
|