tomastrajan / angular-ngrx-material-starter

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

Scrolling issue #499

Open Amitshaale opened 4 years ago

Amitshaale commented 4 years ago

Hi,

On changing route page is showing from bottom it should be from start(Top).

I have tried for fix but still I it's not fixed. can you help please?

my code is here in app.routing.module.ts

RouterModule.forRoot(routes, {
      useHash: false,
      preloadingStrategy: PreloadAllModules,
      initialNavigation: 'enabled',
      scrollPositionRestoration: 'enabled'
    })
tomastrajan commented 4 years ago

Hi @Amitshaale !

Did you try scrollPositionRestoration: 'top'

https://angular.io/api/router/ExtraOptions

Amitshaale commented 4 years ago

Hi @tomastrajan

I have tried this solution but it's not working scrollPositionRestoration: 'top'

tomastrajan commented 4 years ago

@Amitshaale which browser/ os ?

Amitshaale commented 4 years ago

@tomastrajan Chrome in mac os.

I think with module routing it's not working.

Amitshaale commented 4 years ago

@tomastrajan any solution on this issue?

Amitshaale commented 4 years ago

I have tried with this code but still it's not working...

const routerOptions: ExtraOptions = { useHash: false, anchorScrolling: 'enabled', scrollPositionRestoration: 'enabled', scrollOffset: [0, 0] // [x, y] }

Amitshaale commented 4 years ago

@tomastrajan issue still not fixed. how to fix?

varunahuja555 commented 4 years ago

@Amitshaale

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