question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

View breaks when `shadowOffset` property is passed to the `animate` property

See original GitHub issue

Description

When I’m trying to add the shadowOffset style property value to the animate property in MotiView, the view doesn’t render anymore. I’m assuming it could be because shadowOffset has an object-based value and that is breaking something under the hood.

Steps to Reproduce

Code

<MotiView
  from={{ opacity: 0 }}
  animate={{
    opacity: 1,
    shadowColor: "#1A2138",
    shadowOffset: {
      width: 0,
      height: 8,
    },
    shadowOpacity: 0.5,
    shadowRadius: 20,
  }}
  style={{
    width: 200,
    height: 400,
    backgroundColor: "aqua",
  }}
/>

Screenshot

Expected Behaviour

Ideally, the shadow should appear as below (when applied to the regular style property).

Code

<MotiView
  from={{ opacity: 0 }}
  animate={{
    opacity: 1,
  }}
  style={{
    width: 200,
    height: 400,
    backgroundColor: "aqua",
    shadowColor: "#1A2138",
    shadowOffset: {
      width: 40,
      height: 40,
    },
    shadowOpacity: 0.5,
    shadowRadius: 20,
  }}
/>

Screenshot

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
nandorojocommented, Feb 8, 2022

yeah let me see. i know it can be a bit tough, there’s some magic going on in there haha

1reaction
nandorojocommented, Feb 8, 2022

line 531 is what you want. that basically says, if the value for a given style is an object, then go through and apply final[key] = animation(value), where animation is withTiming/withSpring

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to set shadowOffset through reanimated #634 - GitHub
It may be caused when certain properties aren't listed in the config, ... View style={[ { shadowOffset: { height: new Animated.
Read more >
Animatable CSS properties - CSS: Cascading Style Sheets
A CSS property is animatable if its value can be made to change over a given amount of time. Certain CSS properties can...
Read more >
box-shadow - CSS-Tricks
The box-shadow property in CSS is for putting shadows on elements (sometimes referred to as "drop shadows", ala Photoshop/Figma).
Read more >
Stop animating box-shadows the wrong way! - YouTube
You can animate and transition just about anything with CSS, but that doesn't mean that it's a good idea to do it.
Read more >
How to animate box-shadow with silky smooth performance
How do you animate the box-shadow property in CSS without causing ... you should see something similar to this (green bars are paints; ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found