I have an observable tracking the scroll position
const scroll = Observable
.fromEvent(document, 'scroll')
.map(e => window.pageYOffset)
.startWith(0)
I would like to have a second observable tracking the scroll delta (newScroll - lastScroll)
const scrollDelta = scroll
// ???
.subscribe(delta => console.log('delta:', delta) )
How to implement something like this? I've tried with scan with no success. Thx
Use pairwise:
scroll
.pairwise()
.map([a, b] => b - a);
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments