uias / Pageboy

📖 A simple, highly informative page view controller
MIT License
1.99k stars 155 forks source link

Fixed incorrect scrolling to index on pager appearance #175

Closed mlarandeau closed 6 years ago

mlarandeau commented 6 years ago

Issue Replication:

  1. Begin to page to a new index but then stop the gesture early so that the pager stays on the current index
  2. Present and dismiss a view controller over the pager
  3. The pager will now be at the index that you had started to move to, but not the index that you ended at.

Cause: expectedTransitionIndex on PageboyViewController is set when the user begins the paging gesture, however, the expectedTransitionIndex is never cleared and the currentIndex is never updated if the user cancels the gesture. Therefore, when scrollToPage is triggered on viewWillAppear, the expectedTransitionIndex does not match the currentIndex and therefore the pager switches pages even though that is not the intention of the user.

Fix: expectedTransitionIndex is set to nil at the end of the paging/scrolling process.