fix bug that sometimes the swipe gesture works incorrectly