jakespracher / Snapchat-Swipe-View

Handy four way snapchat style scrolling navigation
MIT License
143 stars 19 forks source link

Bottom view allows for right and left scroll #11

Open zalsaeed opened 7 years ago

zalsaeed commented 7 years ago

I think this qualifies to be a bug. However, since I have heavily changed the original code there is a possibility that I have introduce something caused the problem.

In the VericalScrollViewController class the method outerScrollViewShouldScroll if I understand this correctly is responsible of disabling the horizontal scrolling on the outer vertical views (top and bottom). The method works fine for the top view since the condition scrollView.contentOffset.y < middleVc.view.frame.origin.y will catch anything that is placed to the top of the the middle (main) view. However, when it comes to the bottom one the condition scrollView.contentOffset.y > 2*middleVc.view.frame.origin.y is not accurate since it slightly exclude the bottom view. For example, if we arbitrarily assume that the y origin value for the main view is 6 and its height is 6 as well, then the y origin value for the bottom view would be 12. Given the condition 12 is equal to 26 thus the horizontal scrolling is enabled and one can go from the bottom view to the right and left ones. I think the safest is to change the conditional `scrollView.contentOffset.y > 2middleVc.view.frame.origin.ytoscrollView.contentOffset.y > middleVc.view.frame.origin.y. Also, I think it is possible to change the whole condition toif scrollView.contentOffset.y != middleVc.view.frame.origin.y {return false}` but I don't know if this will introduce navigation difficulties due to high accuracy.

Finally, thanks for sharing this.

fatmaakcay commented 7 years ago

Yes, this bug is present in the original code. your first suggestion, to change scrollView.contentOffset.y > 2*middleVc.view.frame.origin.y to scrollView.contentOffset.y > middleVc.view.frame.origin.y works.