
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
ng-scroll-savior
Advanced tools

Save your scroll position in Angular 4+ though all back/forward state transitions, and force scroll to top otherwise (like a normal website).
npm i ng-scroll-savior --save
app.module.ts
@NgModule({
...
imports: [
ScrollSaviorModule.forRoot()
]
...
});
in your app.component.ts
constructor(private router: Router,
private scrollSaviorService: ScrollSaviorService) {
// pass in the router and optional defaults as the second parameter if needed
scrollSaviorService.init(router);
}
Scroll Savior will now save your scroll positions when travelling between all pages, lazy-routes, and different templates, and restore them as necessary.
Default
{
noScrollTag: 'noScroll=true',
containerSelector: '.mat-sidenav-content' // (fallback to `window` (universal safe)
};
Usage
ScrollSaviorModule.forRoot({
noScrollTag: ...
containerSelector: ...
})
Description
| Property | Default | Description |
|---|---|---|
| noScrollTag | 'noScroll=true' | string that can be appended to the end of a route to disable scroll-saving for that route. ez: `https://example.com/something/else?noScroll=true |
| containerSelector | '.mat-sidenav-content' (fallback to window) | The container that is used to check scroll positioning |
Scroll Savior saves each route's scroll position in a HashMap and properly retrieves that position when using either a back/forward button or long-pressing the back/forward button and choosing a route from the browser list.
Scroll savior never adds an observer to your scroll wheel, simply catches the scroll position on a RouteChangeStart event and uses that to determine future positioning
Scroll savior works on lazy loaded routes, or routes using different templates
Safe for use in Angular Universal. Checks to see if the platform is the browser before accessing the window object.
Notes
This doesn't work on Ajax-loaded content
forRoot or allow multiple to be instantiated due to the possibility of wanting multiple containersThanks ~ ❤ Augie Gardner
FAQs
Save your scroll position in Angular
We found that ng-scroll-savior demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.