Merged Jared's code for swipe gestures.