Extend NativeWindow to track touch-based scroll events on OS X
authorBen Gotow <bengotow@gmail.com>
Thu, 21 Jan 2016 17:40:21 +0000 (09:40 -0800)
committerBen Gotow <bengotow@gmail.com>
Thu, 21 Jan 2016 17:40:21 +0000 (09:40 -0800)
commitbd2252ea559db6d95a9eae12913ff4d2e8472c78
tree6fd28fdb5723b83212fd7243be4b308e6a3e4542
parentfda480d1aab57b90ff8cf4b102015464bf0e59a3
Extend NativeWindow to track touch-based scroll events on OS X

In N1, we want to implement the famous "swipe to archive" action on threads in the user's inbox. Chrome exposes `scroll` and `wheel` events, but these aren't sufficient to implement the interaction because the element needs to "snap" when the user lifts their fingers from the trackpad, not when they / we stop receiving `wheel` / `scroll` events. These events may stop before the user lifts their fingers, or continue after the user has lifted their fingers if they had enough momentum for the gesture to continue.

This exposes BrowserWindow `scroll-touch-down` and `scroll-touch-up`, which fire immeditaely when the user touches two fingers to the trackpad, and again when the user lifts their fingers. Combined with the existing wheel event should allow for "swipe-to-archive" and other similar interactions.

Note: This is only implemented on Mac OS X and the events don't fire unless you're using a trackpad!

Related: #1486, #2683, https://github.com/nylas/N1/issues/541
atom/browser/api/atom_api_window.cc
atom/browser/api/atom_api_window.h
atom/browser/native_window.cc
atom/browser/native_window.h
atom/browser/native_window_mac.mm
atom/browser/native_window_observer.h