I was trying to use the scrollIntoView() with smoothscroll.polyfill() but I've tried a couple of times to use this functionality on Microsoft Edge and the text goes on top of screen, but on Mozilla Firefox and Google Chrome centralize the div. Here is the code below:
app.component.html:
<button (click)="scroll()">Click</button>
<div>Hello World</div>
<div>Hello World</div>
[...]
<div class="hello">Hello World Test</div>
[...]
<div>Hello World</div>
<div>Hello World</div>
app.component.ts:
scroll() {
document.querySelector('.hello').scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'center'})
}
Note: I'm using Angular v9.1.0 (Latest).
Thanks for all!