Respect the "vertical" configuration option for touch events

Applying the changes from [this StackOverflow answer](http://stackoverflow.com/a/11941190/339925).