airbnb / lottie-android

Render After Effects animations natively on Android and iOS, Web, and React Native
http://airbnb.io/lottie/
Apache License 2.0
34.95k stars 5.4k forks source link

`clipToCompositionBounds` parameter name is confusing/misleading #2446

Closed undermark5 closed 6 months ago

undermark5 commented 8 months ago

Is your feature request related to a problem? Please describe. While trying to figure out why it seemed as though our use of the LottieAnimation composable was misbehaving, I realized that the clipToCompositionBounds parameter does not refer to Jetpack Compose's composition, but the Lottie animation composition. While the fact that the parameter to specify the animation is composition, the docs don't make the use of referencing that parameter (which would help clarify it's not Jetpack Compose's composition), the clip portion of the name is also misleading because in some circumstances this means that the Lottie will be rendered outside of the containers bounds, which means that in such circumstances, the parameter being true means the lottie will be larger than when the value is set to false

Describe the solution you'd like I propose that the parameter documentation is improved (so that the composition text refers to the composition parameter) and that clip be swapped for expand (or the behavior inverted, such that when clip is true, the results will be smaller than with false, though I feel as though expand is the better approach here)

Describe alternatives you've considered I can obviously write my own wrapper functions, but I'm sure I won't be the first to be confused by the fact that clip == true can mean the Lottie draws outside of the container bounds.

undermark5 commented 8 months ago

Maybe the parameter isn't actually doing what I think it is, turns out our issue was solved by adding a clipToBounds modifier to the Lottie itself, but I feel as though that shouldn't have to be added as a modifier and there should be a way to clip the Lottie to layout bounds directly.