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: README.md
+13-3Lines changed: 13 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,14 +18,16 @@ The text to be measured is required, the rest of the parameters supported are op
18
18
- Allow font scaling
19
19
- Maximum width, for automatic line-break based on text-break strategy.
20
20
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:
22
24
23
25
- The width used by the text, with an option to calculate the real width of the largest line.
24
26
- Height, with or without paddings.
25
27
- The number of lines.
26
28
- The width of the last line, if required, useful to save space with "See more..." style labels or time stamps.
27
29
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.
29
31
30
32
In addition, the library includes functions to obtain information about the fonts visible to the App.
31
33
@@ -180,7 +182,15 @@ Calculate the height of each of the strings in an array.
180
182
181
183
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
184
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
+
| `measure` | `flatHeights`
190
+
------- | --------: | ----------:
191
+
Android | 49,624 | 1,091
192
+
iOS | 1,949 | 732
193
+
184
194
185
195
In the future I will prepare an example of its use with FlatList and multiple styles on the same card.
0 commit comments