react-native-shadow icon indicating copy to clipboard operation
react-native-shadow copied to clipboard

For circle shadow not blending properly from corners

Open ranvirgorai opened this issue 6 years ago • 9 comments

For the circle, the shadow is not blending properly from corners

const shadowOpt1 = {
           width:150,
           height:150,
           color:"#000",
           border:30,
           radius:75,
           opacity:0.2,
           x:0,
           y:0,
           style:{marginVertical:0,marginHorizontal:40,}
       }
screen shot 2018-11-21 at 1 04 39 pm

And if the border-radius is greater then 50% then getting an unexpected result

const shadowOpt1 = {
           width:150,
           height:150,
           color:"#000",
           border:30,
           radius:80,
           opacity:0.2,
           x:0,
           y:0,
           style:{marginVertical:0,marginHorizontal:40,}
       }


screen shot 2018-11-21 at 1 07 03 pm

ranvirgorai avatar Nov 22 '18 06:11 ranvirgorai

I confirm.

dagatsoin avatar Mar 11 '19 08:03 dagatsoin

@dagatsoin @ranvirgorai

I believe that the problem that I have is the one you are referring to.
I am posting this in order to make sure this is the case... Is it? And perhaps anybody has found a solution on how to do this in raect-native (android)...

I want to display something like the following:

image

But what I get is:

image

Here is my code:

class ShadowTest extends Component {

  render() {

    const shadowOpt = {
      width: 100,
      height: 100,
      color: "#000",
      border: 2,
      radius: 50,
      opacity: 0.8,
      x: 3,
      y: 3,
      //style: { marginVertical: 5 }
    }

    return (
      <View style={{ flex: 1 }}>
        <View style={{ margin: 10, alignItems: 'center',
            justifyContent: 'center' }}>
          <BoxShadow setting={ shadowOpt }>
            <TouchableHighlight style={{
              position: 'relative',
              width: 100,
              height: 100,
              backgroundColor: "#fff",
              borderRadius: 50,
              borderWidth: 1,
              borderColor: '#aaa',
              // marginVertical:5,
              alignItems: 'center',
              justifyContent: 'center',
              overflow: "hidden" }}>
              <Text>aaaa</Text>
            </TouchableHighlight>
          </BoxShadow>
          </View>
      </View>
    )
  }
}

rahamin1 avatar Apr 16 '19 07:04 rahamin1

I reimplemented this plugin in a way that supports the round corner. It is part of my library but it is isolated enough to be adapted on any project. Just take care to replace the View element.

Demo for android: https://expo.io/@dagatsoin/sproutch Code: https://github.com/dagatsoin/sproutch/blob/master/src/components/shadow/Shadow.tsx

dagatsoin avatar Apr 16 '19 08:04 dagatsoin

Thanks @dagatsoin Which part of the code implements the circular shadow?

rahamin1 avatar Apr 16 '19 09:04 rahamin1

It is those SVG commands: https://github.com/dagatsoin/sproutch/blob/master/src/components/shadow/Shadow.tsx#L193

dagatsoin avatar Apr 16 '19 10:04 dagatsoin

Thanks!

rahamin1 avatar Apr 16 '19 10:04 rahamin1

I reimplemented this plugin in a way that supports the round corner. It is part of my library but it is isolated enough to be adapted on any project. Just take care to replace the View element.

Demo for android: https://expo.io/@dagatsoin/sproutch Code: https://github.com/dagatsoin/sproutch/blob/master/src/components/shadow/Shadow.tsx

I got an Error while updating property 'd' of a view managed by: RNSVGPath

null

UnexecptedData

Jamyth avatar Feb 04 '20 06:02 Jamyth

@Jamyth try this branch https://github.com/dagatsoin/sproutch/tree/release/0.0.4

This error is due to dependencies mess with the new expo/rn versions.

dagatsoin avatar Feb 04 '20 08:02 dagatsoin

Still no update on this ? Or any workaround ?

SimonChaumet avatar Nov 23 '20 11:11 SimonChaumet