nodebb-plugin-ezoic-infinite 0.6.9 → 0.7.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/package.json +1 -1
- package/public/client.js +29 -1
package/package.json
CHANGED
package/public/client.js
CHANGED
|
@@ -319,5 +319,33 @@ function debounceRefresh() {
|
|
|
319
319
|
}
|
|
320
320
|
|
|
321
321
|
$(document).ready(debounceRefresh);
|
|
322
|
-
$(window).on('action:ajaxify.end action:posts.loaded action:topic.loaded', debounceRefresh);
|
|
322
|
+
$(window).on('action:ajaxify.end action:posts.loaded action:topic.loaded action:topics.loaded action:category.loaded', debounceRefresh);
|
|
323
323
|
setTimeout(debounceRefresh, 2200);
|
|
324
|
+
|
|
325
|
+
// Fallback: some themes/devices don't emit the expected events for infinite scroll.
|
|
326
|
+
// Observe DOM additions and trigger a refresh when new posts/topics are appended/prepended.
|
|
327
|
+
(function setupEzoicObserver() {
|
|
328
|
+
if (window.__ezoicInfiniteObserver) return;
|
|
329
|
+
try {
|
|
330
|
+
const obs = new MutationObserver(function (mutations) {
|
|
331
|
+
for (const m of mutations) {
|
|
332
|
+
if (!m.addedNodes || !m.addedNodes.length) continue;
|
|
333
|
+
for (const n of m.addedNodes) {
|
|
334
|
+
if (!n || n.nodeType !== 1) continue;
|
|
335
|
+
// direct match
|
|
336
|
+
if (n.matches && (n.matches('[component="post"][data-pid]') || n.matches('li[component="category/topic"]'))) {
|
|
337
|
+
debounceRefresh();
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
// descendant match
|
|
341
|
+
if (n.querySelector && (n.querySelector('[component="post"][data-pid]') || n.querySelector('li[component="category/topic"]'))) {
|
|
342
|
+
debounceRefresh();
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
obs.observe(document.body, { childList: true, subtree: true });
|
|
349
|
+
window.__ezoicInfiniteObserver = obs;
|
|
350
|
+
} catch (e) {}
|
|
351
|
+
})();
|