Repository navigation
[iOS] Animate the image view clipping mask along with the view bounds - #60253
dileepapeiris wants to merge 1 commit into
Conversation
|
Hi @dileepapeiris! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Summary:
When a view clips its content,
RCTViewComponentView.invalidateLayerputs aCAShapeLayermask on everyUIImageViewsubview so the image follows the border radius. The mask is a fresh layer whose path is the image view's bounds at layout time. When the layout change is animated by UIKit, for example during a device rotation, the image view's bounds animate but the mask is already at the final size, so the image is clipped to its final size on the first frame while the view is still animating.This is visible with
<Image>directly and with any library that hosts aUIImageViewin a clipping view (expo/expo#54040 is the same bug throughexpo-image).This change reuses the mask layer that is already installed and, when UIKit has added a
bounds.sizeanimation to the image view's layer, copies that animation onto the mask'spathso the mask follows the view with the same timing.Fixes #60252.
Changelog:
[IOS] [FIXED] - Image views in clipping views are no longer clipped to their final size while a layout animation, such as a rotation, is in progress
Test Plan:
Reproducer: https://github.com/dileepapeiris/react-native-image-rotation-mask-repro (community reproducer template, React Native 0.88.1). The screen has a row of three
<Image resizeMode="cover">inside greenoverflow: 'hidden'items, and a control row with plain views. Rotate the simulator from landscape to portrait with Slow Animations on.Before: the image rows show the green item background on the right for the whole rotation, because the image is already clipped to its portrait width. After: the image fills its item through the whole animation. The control row is unchanged.
Portrait and landscape at rest render identically before and after.
Before and after frames, 0.2 s into the rotation, iPhone 17 Pro simulator, iOS 26.5: