Skip to content

Instantly share code, notes, and snippets.

@WillsonSmith
Last active August 29, 2015 14:00
Show Gist options
  • Save WillsonSmith/6226d724098f2d63908d to your computer and use it in GitHub Desktop.
Save WillsonSmith/6226d724098f2d63908d to your computer and use it in GitHub Desktop.
(function(){
'use strict';
var c = document.getElementById('container');
var start,
move,
end;
c.addEventListener('touchstart', function(e){
start = e.pageX;
}, false);
c.addEventListener('touchmove', function(e){
move = e.pageX;
}, false);
c.addEventListener('touchend', function(e){
end = move;
if (start > end){
console.log('swipe left');
}
if (start < end){
console.log('swipe right');
}
}, false);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment