swipe detection from basic principles