Skip to content

Commit 8aa8781

Browse files
ryancatfacebook-github-bot
authored andcommitted
Consider transform when calculating overflowInset values
Summary: The fix in this diff seems simple, but it took some time to understand why this change fixed the issue that views animated use native driver out from their parent's layout are not getting touch events. We introduced `overflowInset` to RN Android a while back to give each shadow node extra information to cover all its children's layout. These values (left, top, right, bottom extensions from the view's own layout) help us improve hit-testing algorithm used in touch events. We could ignore all subtrees that the touch point not in their parent's overflowInset box. However, this was not working for native animation. When `userNativeDriver` is on, all animation happens without Fabric knows anything about them. The overflowInset is out of date with the final animated layout, which caused the issue that we ignored the animated view as we thought it's not under the pointer. Here is a playground demo (P476407654) for the issue: https://pxl.cl/1XfPL We've tried to fix this by passing the final animated values via `passthroughAnimatedPropExplicitValues` added in D32539976. This is a prop that will get merged into `style` prop for [animation component](https://fburl.com/code/jybzfgu5). The transform values were already applied when measuring layout in [Pressability](https://fburl.com/code/5mect2k3), which uses [LayoutableShadowNode](https://fburl.com/code/qh8fufrw). However, this is not the case for overflowInset calculation. Hence, the fix here is to apply the transform matrix in Yoga before calculating the overflowInset. Changelog: [Android][Fixed] - Fix overflowInset calculation by using transform values Reviewed By: ShikaSD Differential Revision: D33806030 fbshipit-source-id: e438618e3d6e5b0333cff9ff9919b841d73b2e9d
1 parent 4b7face commit 8aa8781

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp

+10-1
Original file line numberDiff line numberDiff line change
@@ -528,8 +528,17 @@ void YogaLayoutableShadowNode::layout(LayoutContext layoutContext) {
528528
}
529529

530530
if (yogaNode_.getStyle().overflow() == YGOverflowVisible) {
531+
auto transform = getTransform();
532+
auto transformedContentFrame = contentFrame;
533+
if (Transform::Identity() != transform) {
534+
// When animation uses native driver, Yoga has no knowledge of the
535+
// animation. In case the content goes out from current container, we need
536+
// to union the content frame with its transformed frame.
537+
transformedContentFrame = contentFrame * getTransform();
538+
transformedContentFrame.unionInPlace(contentFrame);
539+
}
531540
layoutMetrics_.overflowInset =
532-
calculateOverflowInset(layoutMetrics_.frame, contentFrame);
541+
calculateOverflowInset(layoutMetrics_.frame, transformedContentFrame);
533542
} else {
534543
layoutMetrics_.overflowInset = {};
535544
}

0 commit comments

Comments
 (0)