scroll into view smooth code example
Example 1: javascript scrollintoview
var element = document.getElementById("box");
element.scrollIntoView();
element.scrollIntoView(false);
element.scrollIntoView({block: "end"});
element.scrollIntoView({behavior: "smooth", block: "end", inline: "nearest"});
Example 2: smooth scroll in viewportscroller
<button (click)="scrollToElement(target)"></button>
<div id="target" #target>Your target</div>
scrollToElement($element): void {
console.log($element);
$element.scrollIntoView({behavior: "smooth", block: "start", inline: "nearest"});
}
Example 3: scrollintoview
element.scrollIntoView();
element.scrollIntoView(alignToTop);
element.scrollIntoView(scrollIntoViewOptions);