tomastrajan / angular-ngrx-material-starter

Angular, NgRx, Angular CLI & Angular Material Starter Project
https://tomastrajan.github.io/angular-ngrx-material-starter
MIT License
2.82k stars 919 forks source link

window.scrollTo not working #502

Closed hieuntp2 closed 3 years ago

hieuntp2 commented 4 years ago

Minimal reproduction of the bug with instructions:

As normal, when we call window.scrollTop(0,0), browser will scroll to top. Or for simple, when scroll bottom of page, open console and call window.scrollTop(0,0), current page will scroll to top.

Expected behavior:

Browser will scroll to expected location.

Other information:

I would be willing to submit a PR to fix this issue:

[ ] Yes (Assistance is provided if you need help submitting a pull request)
[x ] No

tomastrajan commented 4 years ago

Hi @hieuntp2 !

This is a browser API, not Angular itself... Which browser did you try ? Also try to remove router config object with scroll behavior and try again ?

https://github.com/tomastrajan/angular-ngrx-material-starter/blob/master/projects/angular-ngrx-material-starter/src/app/app-routing.module.ts#L43

varunahuja555 commented 3 years ago

@hieuntp2 Try this. It's working const elmnt = document.getElementById(id); elmnt.scrollIntoView({behavior: 'smooth'});