Skip to content

Commit 101f5de

Browse files
Alberto MarinesAlberto Marines
authored andcommitted
2 parents 24b3a1d + a55d3a7 commit 101f5de

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@ The text to be measured is required, the rest of the parameters supported are op
1818
- Allow font scaling
1919
- Maximum width, for automatic line-break based on text-break strategy.
2020

21-
The result includes:
21+
There are two main functions, one to obtain the height of different blocks of text simultaneously, optimized for components such as `<FlatList>`.
22+
23+
The other one gets detailed information about a block of text:
2224

2325
- The width used by the text, with an option to calculate the real width of the largest line.
2426
- Height, with or without paddings.
2527
- The number of lines.
2628
- The width of the last line, if required, useful to save space with "See more..." style labels or time stamps.
2729

28-
...and it is practically identical to the one that React Native would send in the onLayout event using the same parameters.
30+
Both, width and height, are practically the same as those received in the `onLayout` event of a `<Text>` component with the same properties.
2931

3032
In addition, the library includes functions to obtain information about the fonts visible to the App.
3133

@@ -180,7 +182,15 @@ Calculate the height of each of the strings in an array.
180182

181183
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>`.
182184

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).
185+
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 faster... _much faster_ on Android!
186+
187+
I did tests on 5,000 random text blocks and these were the results (ms):
188+
189+
&nbsp; | `measure` | `flatHeights`
190+
------- | --------: | ----------:
191+
Android | 49,624 | 1,091
192+
iOS | 1,949 | 732
193+
184194

185195
In the future I will prepare an example of its use with FlatList and multiple styles on the same card.
186196

0 commit comments

Comments
 (0)