Skip to content

Instantly share code, notes, and snippets.

View SiarheiBokuts's full-sized avatar

Siarhei Bokuts SiarheiBokuts

  • Warsaw
View GitHub Profile
@SiarheiBokuts
SiarheiBokuts / launch.json
Created December 3, 2021 10:41
vsCode debug configs
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug current file",
@SiarheiBokuts
SiarheiBokuts / better-scroll-restoration-logic-angular.ts
Created November 10, 2021 22:35 — forked from iffa/better-scroll-restoration-logic-angular.ts
Custom scroll position restoration logic for Angular 2+, that doesn't consider query parameter changes in route as forward navigation, thus preventing certain scenarios where you don't want query parameter changes to scroll-to-top as they would with 'scrollPositionRestoration: enabled'.
export class AppModule {
constructor(private router: Router, private viewportScroller: ViewportScroller) {
this.handleScrollOnNavigation();
}
/**
* When route is changed, Angular interprets a simple query params change as "forward navigation" too.
* Using the pairwise function allows us to have both the previous and current router events, which we can
* use to effectively compare the two navigation events and see if they actually change route, or only
* the route parameters (i.e. selections stored in query params).