mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-07 22:52:39 +00:00
Simplify observer
This commit is contained in:
@@ -85,20 +85,16 @@ const BrewRenderer = (props)=>{
|
|||||||
anchor.scrollIntoView({ behavior: 'smooth' });
|
anchor.scrollIntoView({ behavior: 'smooth' });
|
||||||
} else {
|
} else {
|
||||||
// Use MutationObserver to wait for the element if it's not immediately available
|
// Use MutationObserver to wait for the element if it's not immediately available
|
||||||
const observer = new MutationObserver((mutations, obs) => {
|
new MutationObserver((mutations, obs) => {
|
||||||
anchor = iframeDoc.querySelector(hash);
|
anchor = iframeDoc.querySelector(hash);
|
||||||
if (anchor) {
|
if (anchor) {
|
||||||
anchor.scrollIntoView({ behavior: 'smooth' });
|
anchor.scrollIntoView({ behavior: 'smooth' });
|
||||||
obs.disconnect();
|
obs.disconnect();
|
||||||
}
|
}
|
||||||
|
}).observe(iframeDoc, {
|
||||||
|
childList : true,
|
||||||
|
subtree : true,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (iframeDoc.body) {
|
|
||||||
observer.observe(iframeDoc.body, {
|
|
||||||
childList: true,
|
|
||||||
subtree: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user