in app.component.html file i have one div element with horizontal scroll and two buttons as Next and Previous. based on these button click i want to move scroll.
I would prefer to use scrollIntoView() method. This method provides smooth scrolling transition effect in the browser when we click on the corresponding element.
@Component({
selector: 'my-app',
template: `
`
})
export class AppComponent {
public arr = ['foo', 'bar', 'baz'];
@ViewChild('panel') public panel:ElementRef;
public moveToSpecificView()(): void {
setTimeout(() => {
this.panel.nativeElement.scrollIntoView({ behavior: 'smooth', block: 'end', inline: 'start' });
});
}
}