React-native: `shadowOffset` is reset when an `Animated.View` is animated

Created on 6 Jul 2017  路  10Comments  路  Source: facebook/react-native

Is this a bug report?

Yes.

Have you read the Bugs section of the Contributing to React Native Guide?

Yes.

Environment

iOS, and on snack.expo.io

  1. Target Platform (e.g. iOS, Android): iOS
  2. Development Operating System (e.g. macOS Sierra, Windows 10): macOS Sierra
  3. Build tools (Xcode or Android Studio version, iOS or Android SDK version, if relevant): Xcode, snack.expo.io

Steps to Reproduce

  1. Render an Animated.View with a shadow and shadowOffset (eg. {width: 10, height: 10})
  2. Animate any transform with an Animated.Value
  3. Observe shadowOffset is affected. (shadowOpacity, and shadowRadius are unaffected)

https://snack.expo.io/rkBBhJ3Nb

Expected Behavior

shadowOffset should persist

Actual Behavior

shadowOffset does not persist

Reproducible Demo

https://snack.expo.io/rkBBhJ3Nb

Note: none of the shadow properties are being animated.

A way to fix this is to wrap the styled-shadowed View with an Animated.View and animate that instead.

@janicduplessis any thoughts?

Locked

Most helpful comment

Both those workarounds are great. But there's still a bug

All 10 comments

Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally!

If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:

  • Does the issue still reproduce on the latest release candidate? Post a comment with the version you tested.
  • If so, is there any information missing from the bug report? Post a comment with all the information required by the issue template.
  • Is there a pull request that addresses this issue? Post a comment with the PR number so we can follow up.

If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution.

It worked for me by using an animated value on it

shadowOffset: {
  width: 0,
  height: this.deltaY.interpolate({
    inputRange: [-60, 0],
    outputRange: [20, 0]
  })
 }

Another solution to this is wrapping the content of the Animatable into another View and applying the shadowOffset to it.
https://github.com/oblador/react-native-animatable/issues/133

Both those workarounds are great. But there's still a bug

Definitely a bug and should be reopened. I just encountered this exact issue.

@gastonmorixe Do you know if there is a way to make it work when animating shadowOpacity?

Yup, the same thing applies to text shadows. Definitely a bug.

Any solution yet? the two above didn't work for me :(
Thanks.

Still a bug, should be re-opened.

I've just encountered this as well

Was this page helpful?
0 / 5 - 0 ratings