-
Notifications
You must be signed in to change notification settings - Fork 61
Replace onLayoutMeasured
with onLayout
#133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
originalX: 0, | ||
originalY: 0, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
lib/typescript/typings/index.d.ts
Outdated
panAnimatedValueXY?: Animated.ValueXY; | ||
debug?: boolean; | ||
onLayoutMeasured?: (size: Size2D & Vec2D) => void; | ||
onLayout?: (size: Size2D & Vec2D) => void; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onLayout
instead of onLayoutMeasured
onLayoutMeasured
with onLayout
onLayoutMeasured
is a bit complicated to wrap our head around, so we should exposeonLayout
instead which is more familiar. This also makes thex, y
exposed byonLayout
consistent with the ones returned byView.onLayout