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

Allow user press through lottie animation when pointerEvents='none'

Open sdg9 opened this issue 3 years ago • 2 comments

React Native supports pointerEvents but they don't work as expected with LottieView.

Scenario

<View>
  <LottieView 
    pointerEvents="none"
    style={{ position: 'absolute', zIndex: 1, width: 500 }}
    source={require('./someAnimation.json')}
    autoPlay={true}
  />
  <TextInput placeholder="Type here" />
</View>
  • LottieView is absolutely positioned with zIndex of 1 so that animations play on top of existing content.
  • The pointerEvents="none" prop is added to LottieView so that lower zIndex components can receive touch events.
  • It does not work as expected as the outermost View of LottieView's implementation doesn't receive the prop.

Proposed Solution

Let the outermost View receive the pointerEvents prop.

Demo

Before

NoTyping zIndex 0 never receives touch event.

After

Typing zIndex 0 receives touch event as expected.

sdg9 avatar Feb 15 '22 01:02 sdg9

@sdg9 @emilioicai We really need this too 😃 , because we are facing production problems due to pointerEvents not working with LottieView

goxr3plus avatar Jul 16 '22 23:07 goxr3plus

Need this ++

Miigaarino avatar Aug 25 '22 08:08 Miigaarino

Hey guys I hope this work for you as it work for me:

const SomeComponent = () => {
    return (
        <>
            ... Some other components
            <View pointerEvents="none" style={{ width: "100%", height: "100%", position: "absolute" }}>
                <LottieView autoPlay source={require('../the-animations-folder/your-animation.json')} />
            </View>
        </>
    )
}

So, you just need to wrap it into a View which should cover the whole screen and which must have the pointerEvents="none"

devpgcs avatar Sep 29 '22 02:09 devpgcs

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Nov 28 '22 05:11 stale[bot]

.

goxr3plus avatar Nov 28 '22 08:11 goxr3plus

Would you please rebase your branch with the master?

matinzd avatar Dec 01 '22 23:12 matinzd

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jan 31 '23 02:01 stale[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 01 '23 14:04 stale[bot]

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

stale[bot] avatar Apr 08 '23 16:04 stale[bot]

Closed in favor of: https://github.com/lottie-react-native/lottie-react-native/pull/992

After merging #992 you can direcetly pass anything you want to the native lottie view itself.

matinzd avatar Apr 11 '23 19:04 matinzd