mirror of
https://github.com/status-im/react-native.git
synced 2025-01-10 17:45:59 +00:00
9dee696ed8
Summary: **Motivation** A basic task of making a React Native ScrollView or ListView scroll to the bottom is currently very hard to accomplish: - https://github.com/facebook/react-native/issues/8003 - https://github.com/facebook/react-native/issues/913 - http://stackoverflow.com/questions/29829375/how-to-scroll-to-bottom-in-react-native-listview **NOTE:** If you're building something like a chat app where you want a ListView to keep scrolling to the bottom at all times, it's easiest to use the [react-native-invertible-scrollview](https://github.com/exponent/react-native-invertible-scroll-view) component rather calling `scrollToEnd` manually when layout changes. The invertible-scrollview uses a clever trick to invert the direction of the ScrollView. This pull request adds a `scrollToEnd` method which scrolls to the bottom if the ScrollView is vertical, to the right if the ScrollView is horizontal. The implementation is based on this SO answer: http://stackoverflow.com/questions/952412/uiscrollview-scrol Closes https://github.com/facebook/react-native/pull/12088 Differential Revision: D4474974 Pulled By: mkonicek fbshipit-source-id: 6ecf8b3435f47dd3a31e2fd5be6859062711c233
33 lines
1.0 KiB
Objective-C
33 lines
1.0 KiB
Objective-C
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*/
|
|
|
|
#import <UIKit/UIKit.h>
|
|
|
|
/**
|
|
* Contains any methods related to scrolling. Any `RCTView` that has scrolling
|
|
* features should implement these methods.
|
|
*/
|
|
@protocol RCTScrollableProtocol
|
|
|
|
@property (nonatomic, readonly) CGSize contentSize;
|
|
|
|
- (void)scrollToOffset:(CGPoint)offset;
|
|
- (void)scrollToOffset:(CGPoint)offset animated:(BOOL)animated;
|
|
/**
|
|
* If this is a vertical scroll view, scrolls to the bottom.
|
|
* If this is a horizontal scroll view, scrolls to the right.
|
|
*/
|
|
- (void)scrollToEnd:(BOOL)animated;
|
|
- (void)zoomToRect:(CGRect)rect animated:(BOOL)animated;
|
|
|
|
- (void)addScrollListener:(NSObject<UIScrollViewDelegate> *)scrollListener;
|
|
- (void)removeScrollListener:(NSObject<UIScrollViewDelegate> *)scrollListener;
|
|
|
|
@end
|