[android] [ios] [web] `measure` returns incorrect values of `View` if its parent `View` is `scale`d using `transform` style
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- C++
- Sterne
- 127k
- Forks
- 25.3k
- Ø Merge
- 1 T. 23 Std.
- Gemergte PRs (30 T.)
- 4
Beschreibung
Description
If use measure method to calculate x, y, width, height, pageX, pageY values of View it will return incorrect values in case if parent View has styles:
transform: [
{
scale: 2,
},
],
in this case width, height, pageX, pageY values from measure callback will be doubled compared to real ones.
Specs
- It is wrong due docs as
transformstyle prop doesnt change layout,transformis used to change appearance only:Transforms are style properties that will help you modify the appearance and position of your components using 2D or 3D transformations. However, once you apply transforms, the layouts remain the same around the transformed component
- It is inconsistent with
react-native-webwheretransformdoesnt affectwidth, height, pageX, pageYvalues - It is inconsistent with response of
onLayoutcallback which will returnwidth, heightNOT scaled
Problem
There are 3 different behaviors:
react-native-webreturns real sizesonLayoutreturns real sizesmeasurereturns size SCALED due to its parenttransformstyle
Steps to reproduce
See example
React Native Version
0.81.5
Affected Platforms
Runtime - Android,
Runtime - iOS,
Runtime - Web
Output of npx @react-native-community/cli info
See example
Stacktrace or Logs
See example console logs on Android (or iOS)
MANDATORY Reproducer
https://snack.expo.dev/@sepu/rn-measure-bug-w-transform
Screenshots and Videos
web console logs (3rd and 4th parameters are the same) which is ok:
>>>>> useLayoutEffect measure x, y, width, height, pageX, pageY 134 351 71 39 134 351
onLayoutHandler layout.x, layout.y, layout.width, layout.height 134 351 71 39
Android / iOS console logs (3rd and 4th parameters for measure are 2x bigger than from onLayout):
>>>>> useLayoutEffect measure x, y, width, height, pageX, pageY 176 456 148 78 139 437
onLayoutHandler layout.x, layout.y, layout.width, layout.height 176 456 74 39
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit dem obligatorischen Snack-Reproducer und vergleiche measure mit onLayout auf Android, iOS und im Web. Verfolge das plattformspezifische Messverhalten, das der Reproducer zeigt; abgeschlossen ist die Aufgabe, wenn measure Werte meldet, die mit dem nicht skalierten Layout sowie den vorhandenen Ergebnissen von Web und onLayout übereinstimmen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, react-native
- Bereich
- mobile-dev
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 50/100