Skip to content

Instantly share code, notes, and snippets.

@rblalock
Last active December 14, 2015 00:59
Show Gist options
  • Save rblalock/5002371 to your computer and use it in GitHub Desktop.
Save rblalock/5002371 to your computer and use it in GitHub Desktop.
// Custom swipe detection for table rows (since technically the "swipe"
// event doesn't apply to individual rows but rather the table. This way we
// don't have to assign a swipe event for each row. One event to manage
// them all is more performant.
var TOUCH_X = 0;
$.list.addEventListener("touchstart", function(e) {
TOUCH_X = e.x;
});
$.list.addEventListener("touchend", function(e) {
if(e.x > (TOUCH_X + 44)) {
// Do things here to the row like add a view overlay that slides in
// e.g. e.source.add( Alloy.createController("rowOverlay") ); ...etc.
} else if(e.x < (TOUCH_X - 44)) {
// Do things here to the row like add a view overlay that slides in
// e.g. e.source.add( Alloy.createController("rowOverlay") ); ...etc.
}
TOUCH_X = e.x;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment