-
-
Save xgrommx/15bfa2709db39988fd1f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const touchStart = Rx.Observable.fromEvent(window, 'touchstart').timestamp(); | |
| const touchMove = Rx.Observable.fromEvent(window, 'touchmmove'); | |
| const touchEnd = Rx.Observable.fromEvent(window, 'touchend').timestamp(); | |
| const touchAndHold = touchStart | |
| .flatMap(() => touchEnd.takeUntil(touchMove), (x, y) => { start: x.timestamp, end: y.timestamp }) | |
| .filter(ts => (ts.end - ts.start) / 1000 > 2); | |
| const subscription = touchAndHold.subscribe( | |
| () => console.log('touch and hold!') | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment