tomastrajan / angular-ngrx-material-starter

Angular, NgRx, Angular CLI & Angular Material Starter Project

Home Page:https://tomastrajan.github.io/angular-ngrx-material-starter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

window.scrollTo not working

hieuntp2 opened this issue · comments

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

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

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