I have different sections with different id's and want to scroll to them. I did it with document.getElementById(id).scrollIntoView(), but then the view will scroll in the middle of the div and not to the beginning. I would prefer a solution with no jquery. So the simplified code looks like this:
CSS
#id1 {
height: 200vh;
background: black;
}
#id2 {
height: 200vh;
background: yellow;
}
HTML
<section id="id1">
<div href="" (click)="scrollTo('id2')">
</section>
<section id="id2">
<div href="" (click)="scrollTo('id1')">
</section>
Javascript
scrollTo(id) {
document.getElementById(id).scrollIntoView({
behavior: "smooth"
});