nodebb-plugin-ezoic-infinite 1.7.58 → 1.7.59
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/package.json +1 -1
- package/public/client.js +3 -66
package/package.json
CHANGED
package/public/client.js
CHANGED
|
@@ -246,63 +246,6 @@
|
|
|
246
246
|
return null;
|
|
247
247
|
}
|
|
248
248
|
|
|
249
|
-
/**
|
|
250
|
-
* Pool épuisé : recycle un wrap loin au-dessus du viewport.
|
|
251
|
-
* Séquence : destroy([id]) → 300ms → define([id]) → 300ms → displayMore([id])
|
|
252
|
-
* Priorité : wraps vides d'abord, remplis si nécessaire.
|
|
253
|
-
*/
|
|
254
|
-
function recycleAndMove(klass, targetEl, newKey) {
|
|
255
|
-
const ez = window.ezstandalone;
|
|
256
|
-
if (typeof ez?.destroyPlaceholders !== 'function' ||
|
|
257
|
-
typeof ez?.define !== 'function' ||
|
|
258
|
-
typeof ez?.displayMore !== 'function') return null;
|
|
259
|
-
|
|
260
|
-
const threshold = -3 * (window.innerHeight || 800);
|
|
261
|
-
let bestEmpty = null, bestEmptyBottom = Infinity;
|
|
262
|
-
let bestFilled = null, bestFilledBottom = Infinity;
|
|
263
|
-
|
|
264
|
-
document.querySelectorAll(`.${WRAP_CLASS}.${klass}`).forEach(wrap => {
|
|
265
|
-
try {
|
|
266
|
-
const rect = wrap.getBoundingClientRect();
|
|
267
|
-
if (rect.bottom > threshold) return;
|
|
268
|
-
if (!isFilled(wrap)) {
|
|
269
|
-
if (rect.bottom < bestEmptyBottom) { bestEmptyBottom = rect.bottom; bestEmpty = wrap; }
|
|
270
|
-
} else {
|
|
271
|
-
if (rect.bottom < bestFilledBottom) { bestFilledBottom = rect.bottom; bestFilled = wrap; }
|
|
272
|
-
}
|
|
273
|
-
} catch (_) {}
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
const best = bestEmpty ?? bestFilled;
|
|
277
|
-
if (!best) return null;
|
|
278
|
-
const id = parseInt(best.getAttribute(A_WRAPID), 10);
|
|
279
|
-
if (!Number.isFinite(id)) return null;
|
|
280
|
-
if (S.recycling.has(id)) return null;
|
|
281
|
-
S.recycling.add(id);
|
|
282
|
-
|
|
283
|
-
const oldKey = best.getAttribute(A_ANCHOR);
|
|
284
|
-
try { const ph = best.querySelector(`#${PH_PREFIX}${id}`); if (ph) S.io?.unobserve(ph); } catch (_) {}
|
|
285
|
-
mutate(() => {
|
|
286
|
-
best.setAttribute(A_ANCHOR, newKey);
|
|
287
|
-
const ph = best.querySelector(`#${PH_PREFIX}${id}`);
|
|
288
|
-
if (ph) ph.innerHTML = '';
|
|
289
|
-
targetEl.insertAdjacentElement('afterend', best);
|
|
290
|
-
});
|
|
291
|
-
if (oldKey && S.wrapByKey.get(oldKey) === best) S.wrapByKey.delete(oldKey);
|
|
292
|
-
S.wrapByKey.set(newKey, best);
|
|
293
|
-
|
|
294
|
-
const doDestroy = () => { try { ez.destroyPlaceholders([id]); } catch (_) {} setTimeout(doDefine, 300); };
|
|
295
|
-
const doDefine = () => { try { ez.define([id]); } catch (_) {} setTimeout(doDisplay, 300); };
|
|
296
|
-
const doDisplay = () => {
|
|
297
|
-
try { ez.displayMore([id]); } catch (_) {}
|
|
298
|
-
S.recycling.delete(id);
|
|
299
|
-
observePh(id);
|
|
300
|
-
};
|
|
301
|
-
try { typeof ez.cmd?.push === 'function' ? ez.cmd.push(doDestroy) : doDestroy(); } catch (_) {}
|
|
302
|
-
|
|
303
|
-
return { id, wrap: best };
|
|
304
|
-
}
|
|
305
|
-
|
|
306
249
|
// ── Wraps DOM — création / suppression ────────────────────────────────────
|
|
307
250
|
|
|
308
251
|
function makeWrap(id, klass, key) {
|
|
@@ -372,14 +315,9 @@
|
|
|
372
315
|
const key = anchorKey(klass, el);
|
|
373
316
|
if (findWrap(key)) continue;
|
|
374
317
|
const id = pickId(poolKey);
|
|
375
|
-
if (id)
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
} else {
|
|
379
|
-
const recycled = recycleAndMove(klass, el, key);
|
|
380
|
-
if (!recycled) break;
|
|
381
|
-
inserted++;
|
|
382
|
-
}
|
|
318
|
+
if (!id) break;
|
|
319
|
+
const w = insertAfter(el, id, klass, key);
|
|
320
|
+
if (w) { observePh(id); inserted++; }
|
|
383
321
|
}
|
|
384
322
|
return inserted;
|
|
385
323
|
}
|
|
@@ -577,7 +515,6 @@
|
|
|
577
515
|
S.mountedIds.clear();
|
|
578
516
|
S.lastShow.clear();
|
|
579
517
|
S.wrapByKey.clear();
|
|
580
|
-
S.recycling.clear();
|
|
581
518
|
S.inflight = 0;
|
|
582
519
|
S.pending = [];
|
|
583
520
|
S.pendingSet.clear();
|