Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save realtomaszkula/5612588747a8a848c89982523483f596 to your computer and use it in GitHub Desktop.
Save realtomaszkula/5612588747a8a848c89982523483f596 to your computer and use it in GitHub Desktop.
enum Direction {
Up = 'Up',
Down = 'Down'
}
const scroll$ = fromEvent(window, 'scroll').pipe(
throttleTime(10),
map(() => window.pageYOffset),
pairwise(),
map(([y1, y2]): Direction => (y2 < y1 ? Direction.Up : Direction.Down)),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment