Skip to content

Instantly share code, notes, and snippets.

@vonbeitthia
vonbeitthia / better-scroll-restoration-logic-angular.ts
Created July 8, 2021 00:07 — 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).
@startuml
object Car
object Bus
object Tire
object Engine
object Driver
Car <|- Bus
Car *-down- Tire
@startmindmap
+ Solving \n Global \n Warming
++ Eating differently
+++ Vegan
+++ Vegetarian
+++ Less processed foods
+++ Buy local food
++ Travel
+++ Bike more
@vonbeitthia
vonbeitthia / devmode-console-helper.js
Created October 27, 2020 19:55 — forked from onestepcreative/devmode-console-helper.js
Color code your console log messages with a shorter syntax to console.log and easily turn off console logging by setting a DEV_MODE variable to false.
/*
Author: Josh McDonald
Twitter: @onestepcreative
Website: joshmcdonald.net
A simple helper to log color coded messages to the
javascript console, using a shorter syntax to console.log
You can leave your dev.log() statements scattered throughout
{"lastUpload":"2021-03-09T23:41:41.734Z","extensionVersion":"v3.4.3"}