Add onTextLayout to TextProps

Summary: Splitting this into a separate diff for OSS

Reviewed By: yungsters

Differential Revision: D9551085

fbshipit-source-id: 8ca08351c6b89cd0011aab3c47ef6cc28b763450
This commit is contained in:
Emily Janzer 2018-08-30 09:26:21 -07:00 committed by Facebook Github Bot
parent b8f6adf654
commit 1736be5811
2 changed files with 17 additions and 1 deletions

View File

@ -10,7 +10,7 @@
'use strict';
import type {LayoutEvent, PressEvent} from 'CoreEventTypes';
import type {LayoutEvent, PressEvent, TextLayoutEvent} from 'CoreEventTypes';
import type React from 'React';
import type {DangerouslyImpreciseStyleProp} from 'StyleSheet';
import type {
@ -48,6 +48,7 @@ export type TextProps = $ReadOnly<{
onResponderTerminate?: ?Function,
onResponderTerminationRequest?: ?Function,
onStartShouldSetResponder?: ?Function,
onTextLayout?: ?(event: TextLayoutEvent) => mixed,
pressRetentionOffset?: ?PressRetentionOffset,
selectable?: ?boolean,
style?: ?DangerouslyImpreciseStyleProp,

View File

@ -36,12 +36,27 @@ export type Layout = $ReadOnly<{|
height: number,
|}>;
export type TextLayout = $ReadOnly<{|
...Layout,
ascender: number,
capHeight: number,
descender: number,
text: string,
xHeight: number,
|}>;
export type LayoutEvent = SyntheticEvent<
$ReadOnly<{|
layout: Layout,
|}>,
>;
export type TextLayoutEvent = SyntheticEvent<
$ReadOnly<{|
lines: Array<TextLayout>,
|}>,
>;
export type PressEvent = SyntheticEvent<
$ReadOnly<{|
changedTouches: $ReadOnlyArray<$PropertyType<PressEvent, 'nativeEvent'>>,