0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-05-07 18:48:39 +00:00

Merge pull request #4734 from G-Ambatte/fixLinkNavigationPartDeux

Add Navigation API check
This commit is contained in:
G.Ambatte
2026-04-16 06:41:36 +12:00
committed by GitHub
@@ -135,6 +135,7 @@ const BrewRenderer = (props)=>{
const mainRef = useRef(null); const mainRef = useRef(null);
const pagesRef = useRef(null); const pagesRef = useRef(null);
const urlRef = useRef('');
if(props.renderer == 'legacy') { if(props.renderer == 'legacy') {
rawPages = props.text.split(PAGEBREAK_REGEX_LEGACY); rawPages = props.text.split(PAGEBREAK_REGEX_LEGACY);
@@ -272,11 +273,12 @@ 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);
navigation.addEventListener('navigate', (e)=>{ window.addEventListener('hashchange', ()=>{
if(e.hashChange && e.destination.sameDocument){ scrollToHash(window.location.hash);
const dest = e.destination.url.slice(e.destination.url.indexOf('#')); });
scrollToHash(dest);
} window.onbeforeunload(()=>{
window.removeEventListener('hashchange');
}); });
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