Skip to content

Conversation

@j-piasecki
Copy link
Member

Description

I noticed that on iOS, Animated Events with no native driver weren't working. This was caused by the fact that Animated events were only sent using the old pipeline, so that NativeAnimatedModule would intercept them. However, when not using the native driver, the event handler is just a JS function, which was effectively ignored.

Test plan

Checked the NativeDetector screen with the useNativeDriver set to false.

Comment on lines 470 to 471
RNGestureHandlerEvent *gestureEvent = (RNGestureHandlerEvent *)event;
auto nativeEvent = [gestureEvent getNativeEvent];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about inline cast?

Suggested change
RNGestureHandlerEvent *gestureEvent = (RNGestureHandlerEvent *)event;
auto nativeEvent = [gestureEvent getNativeEvent];
auto nativeEvent = [(RNGestureHandlerEvent *)event getNativeEvent];

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, we have to send both simultaneously

[self sendEventForNativeAnimatedEvent:event];

and

[(RNGestureHandlerDetector *)detectorView dispatchAnimatedGestureEvent:nativeEvent];

right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cast was repeated in every branch, so I moved it outside of the switch expression. It's now just after the if, which checks if the cast is safe, so it should be easier to read.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, we have to send both simultaneously

We have to send one for the native driver and the other for the JS driver. Hopefully, the C++ Animated will be able to read the events sent through the codegened path, and we will be able to remove one of those in the future.

@j-piasecki j-piasecki merged commit 1fbdbcc into next Nov 28, 2025
3 checks passed
@j-piasecki j-piasecki deleted the @jpiasecki/fix-non-native-animated-events-ios branch November 28, 2025 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants