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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user