Fix scroll preservation on reader setting changes

Observers got disconnected and started again.
Since the images have already been rendered at this point of time, the mutation observer on the scroll element does not detect them anymore.
Thus, exiting image resizes were not observed anymore and did not trigger the preservation logic
This commit is contained in:
schroda
2026-06-16 18:40:52 +02:00
parent dbf8500709
commit 0c246ade2f
2 changed files with 9 additions and 1 deletions

View File

@@ -164,10 +164,14 @@ const useScrollPreservationData = (
updateObservation(entry.removedNodes, (element) => intersectionObserver.unobserve(element));
}
});
mutationObserver.observe(scrollElement, {
childList: true,
subtree: true,
});
updateObservation(scrollElement.childNodes, (element) => intersectionObserver.observe(element));
return () => {
mutationObserver.disconnect();
intersectionObserver.disconnect();
@@ -253,6 +257,8 @@ const usePreserveOnLeadingPageRender = (
subtree: true,
});
updateObservation(scrollElement.childNodes, (element) => resizeObserver.observe(element));
return () => {
mutationObserver.disconnect();
resizeObserver.disconnect();
@@ -347,6 +353,8 @@ const usePreserveOnInfiniteScrollPreviousChapterInitialRender = (
subtree: true,
});
updateObservation(scrollElement.childNodes, (element) => resizeObserver.observe(element));
return () => {
mutationObserver.disconnect();
resizeObserver.disconnect();