Skip to content

Conversation

thomasttvo
Copy link
Collaborator

onLayoutMeasured is a bit complicated to wrap our head around, so we should expose onLayout instead which is more familiar. This also makes the x, y exposed by onLayout consistent with the ones returned by View.onLayout

Comment on lines +45 to +46
originalX: 0,
originalY: 0,
Copy link
Collaborator

@elliottkember elliottkember Jan 24, 2025

Choose a reason for hiding this comment

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

This looks great but I'm confused about the original prefix on these variables. Like we change these in state? These aren't just originals? Probably fine though because these aren't exposed anywhere. And consistent with the other state variables too.

Copy link
Collaborator Author

@thomasttvo thomasttvo Jan 24, 2025

Choose a reason for hiding this comment

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

They represent the "original" layout of the zoomed and panned view to communicate that they are not the post-transformed values. Probably will need to figure out a better prefix

panAnimatedValueXY?: Animated.ValueXY;
debug?: boolean;
onLayoutMeasured?: (size: Size2D & Vec2D) => void;
onLayout?: (size: Size2D & Vec2D) => void;
Copy link
Collaborator

@elliottkember elliottkember Jan 24, 2025

Choose a reason for hiding this comment

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

I think this is definitely better, but the difference between this and ViewProps#onLayout is that it's not keyed by event so this will still be a breaking change that we might be able to avoid:

onLayout?: ((event: LayoutChangeEvent) => void) | undefined;

Is it possible to synthesize an event here somehow? Or force the onLayout event? Or better yet just return a union type?

onLayout?: (( event: LayoutChangeEvent | { nativeEvent: { layout: LayoutRectangle } }

As long as the two are otherwise identical, the consumer will still be able to use event.nativeEvent.layout without changes and be blissfully unaware that something other than View.onLayout was called. Which is nice.

We probably also want useLayout={props.useLayout} on the root View element? We could also spread {...rest} to spread all the other props into the root View, in case people use those but – we weren't doing this already so I doubt it's a problem.

It's also not called when onLayout is called in the view component – we could probably just spread the props into the View with {...rest} and it would still call

Copy link
Collaborator

@elliottkember elliottkember left a comment

Choose a reason for hiding this comment

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

:shipit:

@thomasttvo thomasttvo changed the title Replace onLayout instead of onLayoutMeasured Replace onLayoutMeasured with onLayout Jan 24, 2025
@thomasttvo thomasttvo merged commit bbe861f into master Jan 24, 2025
1 check passed
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.

2 participants