mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: Historically, `UIScrollView`s in React Native do not cancel touches started on `UIControl`-based views (as normal iOS `UIScrollView`s do). This diff implements this behavior. Changelog: [Internal] Fabric-specific internal change. Reviewed By: JoshuaGross Differential Revision: D24661106 fbshipit-source-id: 1fb98d62f9e1528f11e7699d460aaefcec534e97
58 lines
2.2 KiB
Objective-C
58 lines
2.2 KiB
Objective-C
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#import <UIKit/UIKit.h>
|
|
|
|
#import <React/RCTGenericDelegateSplitter.h>
|
|
#import <React/RCTViewComponentView.h>
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
/*
|
|
* Many `UIScrollView` customizations normally require creating a subclass which is not always convenient.
|
|
* `RCTEnhancedScrollView` has a delegate (conforming to this protocol) that allows customizing such behaviors without
|
|
* creating a subclass.
|
|
*/
|
|
@protocol RCTEnhancedScrollViewOverridingDelegate <NSObject>
|
|
|
|
- (BOOL)touchesShouldCancelInContentView:(UIView *)view;
|
|
|
|
@end
|
|
|
|
/*
|
|
* `UIScrollView` subclass which has some improvements and tweaks
|
|
* which are not directly related to React Native.
|
|
*/
|
|
@interface RCTEnhancedScrollView : UIScrollView
|
|
|
|
/*
|
|
* Returns a delegate splitter that can be used to create as many `UIScrollView` delegates as needed.
|
|
* Use that instead of accessing `delegate` property directly.
|
|
*
|
|
* This class overrides the `delegate` property and wires that to the delegate splitter.
|
|
*
|
|
* We never know which another part of the app might introspect the view hierarchy and mess with `UIScrollView`'s
|
|
* delegate, so we expose a fake delegate connected to the original one via the splitter to make the component as
|
|
* resilient to other code as possible: even if something else nil the delegate, other delegates that were subscribed
|
|
* via the splitter will continue working.
|
|
*/
|
|
@property (nonatomic, strong, readonly) RCTGenericDelegateSplitter<id<UIScrollViewDelegate>> *delegateSplitter;
|
|
|
|
@property (nonatomic, weak) id<RCTEnhancedScrollViewOverridingDelegate> overridingDelegate;
|
|
@property (nonatomic, assign) BOOL pinchGestureEnabled;
|
|
@property (nonatomic, assign) BOOL centerContent;
|
|
@property (nonatomic, assign) CGFloat snapToInterval;
|
|
@property (nonatomic, copy) NSString *snapToAlignment;
|
|
@property (nonatomic, assign) BOOL disableIntervalMomentum;
|
|
@property (nonatomic, assign) BOOL snapToStart;
|
|
@property (nonatomic, assign) BOOL snapToEnd;
|
|
@property (nonatomic, copy) NSArray<NSNumber *> *snapToOffsets;
|
|
|
|
@end
|
|
|
|
NS_ASSUME_NONNULL_END
|