RCTScrollView.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. #import <UIKit/UIScrollView.h>
  8. #import <React/RCTAutoInsetsProtocol.h>
  9. #import <React/RCTEventDispatcher.h>
  10. #import <React/RCTScrollableProtocol.h>
  11. #import <React/RCTView.h>
  12. @protocol UIScrollViewDelegate;
  13. @interface RCTScrollView : RCTView <UIScrollViewDelegate, RCTScrollableProtocol, RCTAutoInsetsProtocol>
  14. - (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher NS_DESIGNATED_INITIALIZER;
  15. /**
  16. * The `RCTScrollView` may have at most one single subview. This will ensure
  17. * that the scroll view's `contentSize` will be efficiently set to the size of
  18. * the single subview's frame. That frame size will be determined somewhat
  19. * efficiently since it will have already been computed by the off-main-thread
  20. * layout system.
  21. */
  22. @property (nonatomic, readonly) UIView *contentView;
  23. /**
  24. * If the `contentSize` is not specified (or is specified as {0, 0}, then the
  25. * `contentSize` will automatically be determined by the size of the subview.
  26. */
  27. @property (nonatomic, assign) CGSize contentSize;
  28. /**
  29. * The underlying scrollView (TODO: can we remove this?)
  30. */
  31. @property (nonatomic, readonly) UIScrollView *scrollView;
  32. @property (nonatomic, assign) UIEdgeInsets contentInset;
  33. @property (nonatomic, assign) BOOL automaticallyAdjustContentInsets;
  34. @property (nonatomic, assign) BOOL DEPRECATED_sendUpdatedChildFrames;
  35. @property (nonatomic, assign) NSTimeInterval scrollEventThrottle;
  36. @property (nonatomic, assign) BOOL centerContent;
  37. @property (nonatomic, copy) NSDictionary *maintainVisibleContentPosition;
  38. @property (nonatomic, assign) BOOL scrollToOverflowEnabled;
  39. @property (nonatomic, assign) int snapToInterval;
  40. @property (nonatomic, assign) BOOL disableIntervalMomentum;
  41. @property (nonatomic, copy) NSArray<NSNumber *> *snapToOffsets;
  42. @property (nonatomic, assign) BOOL snapToStart;
  43. @property (nonatomic, assign) BOOL snapToEnd;
  44. @property (nonatomic, copy) NSString *snapToAlignment;
  45. @property (nonatomic, assign) BOOL inverted;
  46. // NOTE: currently these event props are only declared so we can export the
  47. // event names to JS - we don't call the blocks directly because scroll events
  48. // need to be coalesced before sending, for performance reasons.
  49. @property (nonatomic, copy) RCTDirectEventBlock onScrollBeginDrag;
  50. @property (nonatomic, copy) RCTDirectEventBlock onScroll;
  51. @property (nonatomic, copy) RCTDirectEventBlock onScrollToTop;
  52. @property (nonatomic, copy) RCTDirectEventBlock onScrollEndDrag;
  53. @property (nonatomic, copy) RCTDirectEventBlock onMomentumScrollBegin;
  54. @property (nonatomic, copy) RCTDirectEventBlock onMomentumScrollEnd;
  55. @end
  56. @interface RCTScrollView (Internal)
  57. - (void)updateContentOffsetIfNeeded;
  58. @end
  59. @interface RCTEventDispatcher (RCTScrollView)
  60. /**
  61. * Send a fake scroll event.
  62. */
  63. - (void)sendFakeScrollEvent:(NSNumber *)reactTag;
  64. @end