I am sure i must be doing something wrong but can't figure out what. Need some help/pointers.
I am using Angular 10. I have enabled anchorScrolling in app-routing.module
const routes: Routes = [
{ path: 'docs', component: DocsComponent }
];
@NgModule({
imports: [RouterModule.forRoot(routes, {
useHash: true,
anchorScrolling: 'enabled'
})],
exports: [RouterModule]
})
export class AppRoutingModule { }
This works if the container for the jump-sections (the sections with #id where I want to scoll to) does not have property overflow:auto set , but if I set the property overflow:auto then the scrolling stops working through anchorScrolling. I can still scroll manually or by typing the url along with the fragment.
I have created a StackBlitz project to demonstrate this. The project here is working by default
https://stackblitz.com/edit/angular-ivy-ub5k7q
However if you add
overflow:auto
to the
.sections
class in the hello.component.css you will see that the section links give at the top don't result in scroll even though the url does get updated with the correct route#fragment.
Is this an expected behavior?