react-native/React
siddhantsoni 16c9e5b715 Fix: Added scroll Bounds check in scrollToOffset method in RCTScrollView on iOS
Summary:
<!--
Thank you for sending the PR! We appreciate you spending the time to work on these changes.

Help us understand your motivation by explaining why you decided to make this change.

You can learn more about contributing to React Native here: http://facebook.github.io/react-native/docs/contributing.html

Happy contributing!

-->

The scrollToOffset method of RCTScrollView for iOS does not include bound check for the scroll offset provided to the method. This can cause the whole view to scroll out of screen if the offset provided is greater than the bounds of the View.
The same does not happen on Android, where the scroll halts once the last item of the scrollView is in the viewport.
I have added bounds check so the offset resets to the MaxOffset which makes sure the view does not scroll out of the viewport.

The issue can be observed in the following snack:
https://snack.expo.io/H1363Uo8f

![ezgif com-optimize 1](https://user-images.githubusercontent.com/16662518/36068270-2437ae88-0ef7-11e8-96dd-819b4ae0fd67.gif)

To test my changes I ran the code provided in the snack above with the react-native dependency pointing to my branch. As can be see in the video attached below, the scroll halts once it hits the end of the ScrollView even if the scroll offset provided is higher than the bounds of the ScrollView. It also does not scroll up for negative scroll offset.

![ezgif com-optimize](https://user-images.githubusercontent.com/16662518/36068130-9ae4f918-0ef3-11e8-8728-af7b2888bdb8.gif)

[IOS] [BUGFIX] [ScrollView] - Added bounds check to prevent ScrollView from scrolling to an offset which is out of bounds of the ScrollView for iOS.
Closes https://github.com/facebook/react-native/pull/17927

Differential Revision: D7014466

Pulled By: shergin

fbshipit-source-id: a817738d08e1057a4c70f43373132f88fa1461c4
2018-02-25 22:18:31 -08:00
..
Base RCTSurface: Support for synchronous waiting for mounting stage 2018-02-20 22:19:45 -08:00
CxxBridge Update license headers for MIT license 2018-02-16 18:31:53 -08:00
CxxModule Update license headers for MIT license 2018-02-16 18:31:53 -08:00
CxxUtils Update license headers for MIT license 2018-02-16 18:31:53 -08:00
DevSupport Update license headers for MIT license 2018-02-16 18:31:53 -08:00
Fabric update FabricUIManager to call the right JS object 2018-02-23 17:04:40 -08:00
Inspector Forward VM version to inspector 2018-02-13 08:16:50 -08:00
Modules New UIManager API allowing intercept/delay mounting process 2018-02-20 22:19:45 -08:00
Profiler Update license headers for MIT license 2018-02-16 18:31:53 -08:00
React.xcodeproj Add constructor in YGLayout 2018-02-20 05:55:36 -08:00
UIUtils Update license headers for MIT license 2018-02-16 18:31:53 -08:00
Views Fix: Added scroll Bounds check in scrollToOffset method in RCTScrollView on iOS 2018-02-25 22:18:31 -08:00
third-party.xcconfig More attempts to fix Travis CI runs 2017-05-10 04:32:54 -07:00