Skip to content
This repository has been archived by the owner on Nov 11, 2024. It is now read-only.

Commit

Permalink
nit: clean up RCTNativeScrollView
Browse files Browse the repository at this point in the history
  • Loading branch information
aleclarson committed Aug 10, 2019
1 parent 7fb29d3 commit ff5024c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 37 deletions.
46 changes: 11 additions & 35 deletions React/Views/ScrollView/RCTScrollView.m
Original file line number Diff line number Diff line change
Expand Up @@ -175,22 +175,20 @@ @implementation RCTNativeScrollView
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher
{
if ((self = [super initWithFrame:CGRectZero])) {
_backgroundColor = [NSColor clearColor];
_eventDispatcher = eventDispatcher;
_backgroundColor = NSColor.clearColor;
_cachedChildFrames = [NSMutableArray new];
_lastClippedToRect = CGRectNull;

// Note: This also makes "opaque" return NO.
[self setDrawsBackground:NO];

[self.contentView setPostsBoundsChangedNotifications:YES];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(boundsDidChange:)
name:NSViewBoundsDidChangeNotification
object:self.contentView];

_scrollEventThrottle = 0.0;
_lastScrollDispatchTime = CACurrentMediaTime();
_cachedChildFrames = [NSMutableArray new];
_lastClippedToRect = CGRectNull;

}
return self;
}
Expand All @@ -208,14 +206,18 @@ - (void)insertReactSubview:(NSView *)view atIndex:(__unused NSInteger)atIndex
}
}

- (void)removeReactSubview:(__unused NSView *)subview
{
// The "documentView" is never removed.
}

- (void)setAutoScrollToBottom:(BOOL)autoScrollToBottom
{
_autoScrollToBottom = autoScrollToBottom;
[self setDocumentView:[self documentView]];
[self setFrame:[self frame]];
}


- (void)setFrame:(NSRect)frameRect
{
BOOL autoScroll = NO;
Expand Down Expand Up @@ -294,32 +296,6 @@ - (void)scrollToBottom
[[self documentView] scrollPoint:NSMakePoint(0, 100000)]; // TODO: avoid this hack
}

- (BOOL)opaque
{
return NO;
}

- (void)setShowsVerticalScrollIndicator:(BOOL)value
{
self.hasVerticalScroller = value;
}

- (void)setShowsHorizontalScrollIndicator:(BOOL)value
{
self.hasHorizontalScroller = value;
}

- (void)removeReactSubview:(NSView *)subview
{
[subview removeFromSuperview];
}


- (BOOL)isFlipped
{
return YES;
}

- (void)setBackgroundColor:(NSColor *)backgroundColor
{
if ([_backgroundColor isEqual:backgroundColor] || backgroundColor == NULL) {
Expand Down
4 changes: 2 additions & 2 deletions React/Views/ScrollView/RCTScrollViewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ - (NSView *)view
// RCT_EXPORT_VIEW_PROPERTY(scrollsToTop, BOOL)
#endif

RCT_EXPORT_VIEW_PROPERTY(showsHorizontalScrollIndicator, BOOL)
RCT_EXPORT_VIEW_PROPERTY(showsVerticalScrollIndicator, BOOL)
RCT_REMAP_VIEW_PROPERTY(showsHorizontalScrollIndicator, hasHorizontalScroller, BOOL)
RCT_REMAP_VIEW_PROPERTY(showsVerticalScrollIndicator, hasVerticalScroller, BOOL)
RCT_EXPORT_VIEW_PROPERTY(scrollEventThrottle, NSTimeInterval)
RCT_EXPORT_VIEW_PROPERTY(zoomScale, CGFloat)
RCT_EXPORT_VIEW_PROPERTY(contentInset, UIEdgeInsets)
Expand Down

0 comments on commit ff5024c

Please sign in to comment.