You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
4
4
5
5
## [Unreleased]
6
6
7
+
## [2.0.0-beta.5] - 2018-08-21
8
+
7
9
### Added
10
+
- New function `flatHeights` to calculate the height of multiple strings at once, much faster than` measure`.
8
11
- Revised REAME. Now it's clearer, part of its content moved to the Wiki.
9
12
- Docummented the iOS only properties `capHeight` and `xHeight` from the `fontFromSpecs` result.
10
13
- New flag `usePreciseWidth` (default `false`) request the most accurate calculation of the width (Android) and the value of `lastWidth` (both), but its is a bit slower.
Copy file name to clipboardExpand all lines: README.md
+44Lines changed: 44 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -72,6 +72,10 @@ This function measures the text like RN does when the text does not have embedde
72
72
73
73
If you provide the `width`, the measurement will apply the restriction and take into account the automatic line breaks, in addition to the explicit ones.
74
74
75
+
**NOTE:**
76
+
77
+
Although this function is accurate and provides complete information, it can be heavy if the text is a lot, like the one that can be displayed in a FlatList. For these cases, it is better to use `flatHeights` which is much faster.
78
+
75
79
<aname="tsmeasureparams"></a>**TSMeasureParams**
76
80
77
81
JS object with the text to measure, the maximum width, and properties like ones in the react-native [`<Text>`](https://facebook.github.io/react-native/docs/text) component.
@@ -166,6 +170,46 @@ class Test extends Component<Props, State> {
Calculate the height of each of the strings in an array.
180
+
181
+
This is an alternative to `measure` designed for cases in which you have to calculate the height of numerous text blocks with common characteristics (width, font, etc), a Typical case in the `<FlatList>`.
182
+
183
+
The measurement uses the same algorithm as `measure`, but it returns only the height of each block and, by avoiding multiple steps through the bridge, it is much faster (in my tests, with 3500 random blocks of text, it took 778 ms, while mesure took 33,218).
184
+
185
+
In the future I will prepare an example of its use with FlatList and multiple styles on the same card.
186
+
187
+
**TSHeightsParams**
188
+
189
+
This is an object similar to the one received by measure, with the difference that the text property is an array of strings, and the usePreciseWidth property is ignored.
190
+
191
+
The result is an array with the height of each block, in the same order was given.
192
+
193
+
This is an object similar to the one received by `measure`, but the `text` property is an array of strings and the `usePreciseWidth` property is ignored.
194
+
195
+
Property | Type | Default
196
+
---------- | ------ | --------
197
+
text | string | (none)
198
+
width | number | Infinity
199
+
fontFamily | string | OS dependent
200
+
fontWeight | string | 'normal'
201
+
fontSize | number | 14
202
+
fontStyle | string | 'normal'
203
+
fontVariant | array | (none)
204
+
allowFontScaling | boolean | true
205
+
letterSpacing | number | (none)
206
+
includeFontPadding | boolean | true
207
+
textBreakStrategy | string | 'highQuality'
208
+
209
+
The result is a Promise that resolves to an array with the height of each block (_SP_), in the same order in which they were received.
0 commit comments