Fix gallery swipe

Fixed swipe direction detection and ghost click events when swiping
with a mouse.