mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-05-10 00:58:40 +00:00
Switch to HashChange event listener
This commit is contained in:
@@ -273,24 +273,13 @@ const BrewRenderer = (props)=>{
|
|||||||
const frameDidMount = ()=>{ //This triggers when iFrame finishes internal "componentDidMount"
|
const frameDidMount = ()=>{ //This triggers when iFrame finishes internal "componentDidMount"
|
||||||
scrollToHash(window.location.hash);
|
scrollToHash(window.location.hash);
|
||||||
|
|
||||||
if(navigation) {
|
window.addEventListener('hashchange', ()=>{
|
||||||
navigation.addEventListener('navigate', (e)=>{
|
scrollToHash(window.location.hash);
|
||||||
if(e.hashChange && e.destination.sameDocument){
|
});
|
||||||
const dest = e.destination.url.slice(e.destination.url.indexOf('#'));
|
|
||||||
scrollToHash(dest);
|
window.onbeforeunload(()=>{
|
||||||
}
|
window.removeEventListener('hashchange');
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
urlRef.current = window.location.href;
|
|
||||||
setInterval(()=>{
|
|
||||||
if(window.location.href != urlRef.current){
|
|
||||||
urlRef.current = window.location.href;
|
|
||||||
const tmpURL = new URL(window.location.href);
|
|
||||||
const target = tmpURL.hash;
|
|
||||||
scrollToHash(target);
|
|
||||||
}
|
|
||||||
}, 1000);
|
|
||||||
};
|
|
||||||
|
|
||||||
setTimeout(()=>{ //We still see a flicker where the style isn't applied yet, so wait 100ms before showing iFrame
|
setTimeout(()=>{ //We still see a flicker where the style isn't applied yet, so wait 100ms before showing iFrame
|
||||||
renderPages(); //Make sure page is renderable before showing
|
renderPages(); //Make sure page is renderable before showing
|
||||||
|
|||||||
Reference in New Issue
Block a user