1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-21 04:50:55 +01:00
phorge-phorge/scripts
epriestley 6b5204dca9 Add support for device swipe events
Summary:
Ref T2700. Allow JS to listen for swipes on devices.

There are a bunch of tricky cases here and I probably didn't get them all totally right, but this interaction broadly looks like this:

  - We implement gesture recognition for the mouse in device modes (narrow browser), and for touch events from an actual device.
  - The sigil `touchable` indicates that a node wants to react to touch events.
  - When the user touches a `touchable` node, we start listening for moves. They might be tapping/clicking (in which case we don't care), but they might also be gesturing.
  - Once the user moves their finger/pointer far enough away from the tap origin, we recognize it as a gesture. I hardcoded this at 20px; I wasn't able to find any "official" Apple value, but 20px seems like a common default.
  - At this point, we look at where their finger has moved.
    - If they moved it mostly up/down, we interpret the gesture as "scroll" and just stop listening. The device does its own thing.
    - However, if they moved it mostly left/right, we interpret it as a "swipe". We start killing the moves so the device doesn't scroll.
  - Once we've recognized that a gesture is underway, we send a "gesture.swipe.start" event and then "gesture.swipe.move" events for every move.
  - When the user ends the gesture, we send "gesture.swipe.end".
  - If the user cancels the gesture (currently, only by tapping with a second finger), we send "gesture.swipe.cancel".
  - Gesture events have raw position data and some convenience fields.

Test Plan:
Wrote UI example and used it from the Desktop, iPhone simulator, and a real iphone.

  - The code always seems to get "scroll" vs "swipe" correct (i.e., consistent with my intentions).
  - The threshold feels pretty good to me.
  - Tapping with a second finger cancels the action.

Reviewers: chad, btrahan

Reviewed By: chad

CC: aran

Maniphest Tasks: T2700

Differential Revision: https://secure.phabricator.com/D5308
2013-03-09 13:53:15 -08:00
..
aphront Delete license headers from files 2012-11-05 11:16:51 -08:00
calendar Increment year. 2013-01-03 05:45:08 -08:00
celerity Fix conpherence sprites 2013-02-15 19:04:25 -08:00
daemon Remove legacy support for 'phd repository-launch' and 'phd repository-launch-readonly' 2013-01-22 12:26:08 -08:00
differential Delete license headers from files 2012-11-05 11:16:51 -08:00
diviner Port Diviner Core to Phabricator 2013-01-07 14:04:23 -08:00
drydock Allow leases to be explicitly released via web or CLI 2012-12-14 15:42:58 -08:00
fact Delete license headers from files 2012-11-05 11:16:51 -08:00
files Store width and height metadata of image files 2013-01-07 09:46:43 -08:00
fpm Delete license headers from files 2012-11-05 11:16:51 -08:00
install Simplify the "update_phabricator.sh" script 2013-02-14 07:22:43 -08:00
mail de-duplicate emails received by phabricator multiple times 2013-01-03 17:04:30 -08:00
profile Delete license headers from files 2012-11-05 11:16:51 -08:00
repository Save blame info to lint messages 2013-03-06 16:19:01 -08:00
search Improve Search architecture 2012-12-21 14:21:31 -08:00
setup Increase the power of bin/config 2013-01-21 15:27:42 -08:00
sql Use --user and --password from bin/storage in PHP migrations 2013-02-25 22:20:23 -08:00
ssh Fix various issues with SSH receivers 2012-12-19 11:11:32 -08:00
symbols Delete license headers from files 2012-11-05 11:16:51 -08:00
user Delete license headers from files 2012-11-05 11:16:51 -08:00
util Delete license headers from files 2012-11-05 11:16:51 -08:00
__init_script__.php Consolidate environmental initialization 2012-12-25 06:15:28 -08:00
celerity_mapper.php Add support for device swipe events 2013-03-09 13:53:15 -08:00