Skip to content

Commit 437b06f

Browse files
philIipfacebook-github-bot
authored andcommitted
hook up onScroll event to RCTTextInputComponentView
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
1 parent b735cdf commit 437b06f

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,15 @@ - (void)textInputDidChangeSelection
394394
}
395395
}
396396

397+
#pragma mark - RCTBackedTextInputDelegate (UIScrollViewDelegate)
398+
399+
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
400+
{
401+
if (_eventEmitter) {
402+
std::static_pointer_cast<TextInputEventEmitter const>(_eventEmitter)->onScroll([self _textInputMetrics]);
403+
}
404+
}
405+
397406
#pragma mark - Native Commands
398407

399408
- (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args
@@ -499,6 +508,22 @@ - (TextInputMetrics)_textInputMetrics
499508
metrics.text = RCTStringFromNSString(_backedTextInputView.attributedText.string);
500509
metrics.selectionRange = [self _selectionRange];
501510
metrics.eventCount = _mostRecentEventCount;
511+
512+
CGPoint contentOffset = _backedTextInputView.contentOffset;
513+
metrics.contentOffset = {contentOffset.x, contentOffset.y};
514+
515+
UIEdgeInsets contentInset = _backedTextInputView.contentInset;
516+
metrics.contentInset = {contentInset.left, contentInset.top, contentInset.right, contentInset.bottom};
517+
518+
CGSize contentSize = _backedTextInputView.contentSize;
519+
metrics.contentSize = {contentSize.width, contentSize.height};
520+
521+
CGSize layoutMeasurement = _backedTextInputView.bounds.size;
522+
metrics.layoutMeasurement = {layoutMeasurement.width, layoutMeasurement.height};
523+
524+
CGFloat zoomScale = _backedTextInputView.zoomScale;
525+
metrics.zoomScale = zoomScale;
526+
502527
return metrics;
503528
}
504529

0 commit comments

Comments
 (0)