Skip to content

Commit

Permalink
fix: android nan layoutScaleFactor
Browse files Browse the repository at this point in the history
  • Loading branch information
HayesGordon committed Nov 7, 2024
1 parent 23cbf89 commit c708c5f
Showing 1 changed file with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,19 +165,12 @@ class RiveReactNativeViewManager : SimpleViewManager<RiveReactNativeView>() {

@ReactProp(name = "layoutScaleFactor")
fun setLayoutScaleFactor(view: RiveReactNativeView, layoutScaleFactor: Double) {
when {
layoutScaleFactor.isNaN() -> {
// Treat as `null` or uninitialized
view.setLayoutScaleFactor(null)
}
layoutScaleFactor == -1.0 -> {
// iOS handles -1.0 as the value where Rive should handle the density
// We force the same for Android on React Native
view.setLayoutScaleFactor(null)
}
else -> {
view.setLayoutScaleFactor(layoutScaleFactor.toFloat())
}
if (!layoutScaleFactor.isNaN() && layoutScaleFactor > 0) {
// Only set layoutScaleFactor if it's a valid positive float
view.setLayoutScaleFactor(layoutScaleFactor.toFloat())
} else {
// Handle other cases, e.g., NaN, -1, or other non-float-like values
view.setLayoutScaleFactor(null)
}
}

Expand Down

0 comments on commit c708c5f

Please sign in to comment.