cssreact-nativez-indexspotify

How would I simulate an Intransitive zIndex in React Native? (A > B > C > A)


I am trying to create this effect, which can be found in the Spotify UI:

enter image description here

It seems that there are the following components:

The problem is, how do they make this work zIndex-wise?

This leaves us with P > I > C > P, so P > P which isn't possible with normal numbers, like those that zIndex is set to. This kind of property is called intransitivity and appears in situations like the game Rock Paper Scissors, where R > S > P > R.

Nevertheless, Spotify somehow managed to pull this off. Does anybody have any idea as to how this might be achieved?

Maybe the fact that React Native uses hierarchy-specific zIndexes rather than global ones could somehow help?


Solution

  • I found the solution - don't use zIndex. It's simply overflow: "hidden".

    <View style={{ overflow: "hidden" }}> {/* pink box */}
      {/* all content inside here will be clipped by the boundary of this view */}
    </View>