I have a little Ionic 6 Vue app which has two menu’s - left and right.
When selecting a book, the right menu lists sub-chapter-links. Scrolling to those sub-chapters in the main view is implemented with the [scrollIntoView][1]
method.
function scrollToElement() {
try {
const elementToScrollTo = divs.value.find((element) => element.localName == scrollStore.scrollElementMain);
if (elementToScrollTo != undefined && elementToScrollTo != elementToScrollTo.offsetTop) {
// scrolling
elementToScrollTo.scrollIntoView();
}
} catch (e) {
// logging scrolling error
}
}
This works fine until user clicks on left menu links where another books is loaded. No error logging, the scrollIntoView-functionality just doesn’t work anymore.
I am not sure why this breaks the scrollIntoView functionality.
Have tried so many other options and approaches, but without any success.
Demo:
Code
full code is on GitHub
Question on stackoverflow
Thank You for your help