Skip to content

Commit

Permalink
hook up onScroll event to RCTTextInputComponentView
Browse files Browse the repository at this point in the history
Summary:
fixing oncall issue: https://fb.workplace.com/groups/rn.support/permalink/7241260632589156/

in this diff, we hook up the event emitter onScroll event to the native text input view

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D32523146

fbshipit-source-id: d8035deacc8a511577a6fb892ac55c9e07b14392
  • Loading branch information
philIip authored and facebook-github-bot committed Nov 19, 2021
1 parent b735cdf commit 437b06f
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,15 @@ - (void)textInputDidChangeSelection
}
}

#pragma mark - RCTBackedTextInputDelegate (UIScrollViewDelegate)

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
if (_eventEmitter) {
std::static_pointer_cast<TextInputEventEmitter const>(_eventEmitter)->onScroll([self _textInputMetrics]);
}
}

#pragma mark - Native Commands

- (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args
Expand Down Expand Up @@ -499,6 +508,22 @@ - (TextInputMetrics)_textInputMetrics
metrics.text = RCTStringFromNSString(_backedTextInputView.attributedText.string);
metrics.selectionRange = [self _selectionRange];
metrics.eventCount = _mostRecentEventCount;

CGPoint contentOffset = _backedTextInputView.contentOffset;
metrics.contentOffset = {contentOffset.x, contentOffset.y};

UIEdgeInsets contentInset = _backedTextInputView.contentInset;
metrics.contentInset = {contentInset.left, contentInset.top, contentInset.right, contentInset.bottom};

CGSize contentSize = _backedTextInputView.contentSize;
metrics.contentSize = {contentSize.width, contentSize.height};

CGSize layoutMeasurement = _backedTextInputView.bounds.size;
metrics.layoutMeasurement = {layoutMeasurement.width, layoutMeasurement.height};

CGFloat zoomScale = _backedTextInputView.zoomScale;
metrics.zoomScale = zoomScale;

return metrics;
}

Expand Down

0 comments on commit 437b06f

Please sign in to comment.