0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 20:42:43 +00:00

Simplify observer

This commit is contained in:
Trevor Buckner
2024-10-22 13:58:35 -04:00
parent 9fbdd24d01
commit 83a48b8d0c

View File

@@ -85,20 +85,16 @@ const BrewRenderer = (props)=>{
anchor.scrollIntoView({ behavior: 'smooth' });
} else {
// 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);
if (anchor) {
anchor.scrollIntoView({ behavior: 'smooth' });
obs.disconnect();
}
}).observe(iframeDoc, {
childList : true,
subtree : true,
});
if (iframeDoc.body) {
observer.observe(iframeDoc.body, {
childList: true,
subtree: true,
});
}
}
};