mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-24 20:42:43 +00:00
Simplify observer
This commit is contained in:
@@ -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,
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user