I have a modal, and anchor tags inside them.
When I navigate from a separate page, to the modal, depending on the element chosen, the scrollIntoView function works, but it inconsistently scrolls different elements to different heights. (The same elements are scrolled to the same position, but different elements scroll to different heights…some even barely scroll into the modal)
I’m using the
this.activatedRoute.fragment.subscribe(fragment => {
if(fragment) {
const element = document.getElementById(fragment);
console.log(element)
if (element) {
element.style.scrollMarginTop = "0px";
element.scrollIntoView({behavior: 'smooth', block: 'start', inline: 'nearest'});
}
} else {
this.topOfPage()?.nativeElement?.scrollIntoView();
}
})
Any ideas?