From cd9660a1eb01322eb57fbc6ad40ede13a232c0e3 Mon Sep 17 00:00:00 2001 From: Ehsan Date: Sun, 8 Nov 2026 16:13:34 +0100 Subject: [PATCH 1/2] fix(ios): keep clipping and corner radius on a recycled EaseView prepareForRecycle reset layer properties that RCTViewComponentView owns (masksToBounds, cornerRadius, backgroundColor, borders, shadow, opacity, transform). RCTViewComponentView keeps _props across recycling and only applies a style value again when it changes, so a view mounted again with the same overflow: 'hidden' and borderRadius stayed unclipped with square corners. Reset only the properties in the previous props' animatedProperties mask, and never masksToBounds. Adds a reproducer under example/app/issues. --- example/app/issues/72/index.tsx | 108 ++++++++++++++++++++++++++++++++ example/src/demos/index.ts | 5 ++ ios/EaseView.mm | 51 +++++++++++---- 3 files changed, 152 insertions(+), 12 deletions(-) create mode 100644 example/app/issues/72/index.tsx diff --git a/example/app/issues/72/index.tsx b/example/app/issues/72/index.tsx new file mode 100644 index 0000000..bd18e3a --- /dev/null +++ b/example/app/issues/72/index.tsx @@ -0,0 +1,108 @@ +import { useState } from 'react'; +import { Pressable, StyleSheet, Text, View } from 'react-native'; +import { Stack } from 'expo-router'; +import { EaseView } from 'react-native-ease'; + +// Issue #72 — iOS: a recycled EaseView loses overflow: 'hidden' and +// borderRadius. +// https://github.com/appandflow/react-native-ease/issues/72 +// +// prepareForRecycle reset masksToBounds and cornerRadius on the layer, but +// RCTViewComponentView keeps _props across recycling and only applies a style +// value again when it changes. Remounted with the same style, the view stays +// unclipped with square corners. +// +// Steps to reproduce: +// 1. A rounded pill clips a larger red square: only a red pill shows. +// 2. Press Unmount, then Mount again (the pill reuses the recycled view). +// 3. Expected: the same red pill, and the mount count goes up. +// Without the fix: the whole 300x300 red square shows, with square corners. + +export default function RecycledClipScreen() { + const [shown, setShown] = useState(true); + const [mounts, setMounts] = useState(1); + + return ( + + + + Press Unmount, then Mount again. Only a rounded red pill must show, not + a red square. Mount #{mounts}. + + + github.com/appandflow/react-native-ease/issues/72 + + + {shown && ( + + + + )} + + { + if (!shown) setMounts((n) => n + 1); + setShown((s) => !s); + }} + > + + {shown ? 'Unmount' : 'Mount again'} + + + + ); +} + +const styles = StyleSheet.create({ + root: { + flex: 1, + padding: 20, + backgroundColor: '#1a1a2e', + }, + body: { + color: '#a0a0c0', + fontSize: 14, + lineHeight: 20, + marginBottom: 8, + }, + link: { + color: '#6666aa', + fontSize: 12, + marginBottom: 28, + }, + stage: { + height: 160, + alignItems: 'center', + justifyContent: 'center', + marginBottom: 28, + }, + pill: { + width: 160, + height: 64, + borderRadius: 32, + overflow: 'hidden', + backgroundColor: '#4a90d9', + }, + oversized: { + width: 300, + height: 300, + backgroundColor: '#e05555', + }, + button: { + alignSelf: 'center', + paddingHorizontal: 20, + paddingVertical: 12, + borderRadius: 10, + backgroundColor: '#16213e', + }, + buttonText: { + color: '#e0e0ff', + fontSize: 15, + fontWeight: '600', + }, +}); diff --git a/example/src/demos/index.ts b/example/src/demos/index.ts index 6244322..e5dab13 100644 --- a/example/src/demos/index.ts +++ b/example/src/demos/index.ts @@ -165,6 +165,11 @@ export const demos: Record = { title: 'Issue #66 — Background loops', section: 'Issues', }, + 'issue-72': { + route: '/issues/72', + title: 'Issue #72 — Recycled clipping', + section: 'Issues', + }, 'issue-loop-cancel': { route: '/issues/loop-cancel', title: 'Audit — Cancelled loop resurrects', diff --git a/ios/EaseView.mm b/ios/EaseView.mm index fa652de..bd98dbc 100644 --- a/ios/EaseView.mm +++ b/ios/EaseView.mm @@ -1664,18 +1664,45 @@ - (void)prepareForRecycle { _transformOriginX = 0.5; _transformOriginY = 0.5; _transformPerspective = 1280.0; - self.layer.anchorPoint = CGPointMake(0.5, 0.5); - self.layer.opacity = 1.0; - self.layer.transform = CATransform3DIdentity; - self.layer.cornerRadius = 0; - self.layer.masksToBounds = NO; - self.layer.backgroundColor = nil; - self.layer.borderWidth = 0; - self.layer.borderColor = nil; - self.layer.shadowOpacity = 0; - self.layer.shadowRadius = 0; - self.layer.shadowColor = nil; - self.layer.shadowOffset = CGSizeZero; + // Reset only what this view animated. RCTViewComponentView keeps _props + // across recycling and diffs the next props against it, so a style value it + // applied (overflow, borderRadius, backgroundColor, ...) is not applied again + // when the next use has the same value. Resetting those layer properties + // here left a reused view unclipped with square corners. Animated properties + // belong to this view and are set again by the next first-mount update. + const auto &oldProps = *std::static_pointer_cast(_props); + const int mask = oldProps.animatedProperties; + if (mask & kMaskAnyTransform) { + self.layer.anchorPoint = CGPointMake(0.5, 0.5); + self.layer.transform = CATransform3DIdentity; + } + if (mask & kMaskOpacity) { + self.layer.opacity = 1.0; + } + if (mask & kMaskBorderRadius) { + self.layer.cornerRadius = 0; + } + if (mask & kMaskBackgroundColor) { + self.layer.backgroundColor = nil; + } + if (mask & kMaskBorderWidth) { + self.layer.borderWidth = 0; + } + if (mask & kMaskBorderColor) { + self.layer.borderColor = nil; + } + if (mask & kMaskShadowOpacity) { + self.layer.shadowOpacity = 0; + } + if (mask & kMaskShadowRadius) { + self.layer.shadowRadius = 0; + } + if (mask & kMaskShadowColor) { + self.layer.shadowColor = nil; + } + if (mask & kMaskShadowOffset) { + self.layer.shadowOffset = CGSizeZero; + } } @end From e63c5b7cfa12114b4eb2bd75ed389829b60f37bb Mon Sep 17 00:00:00 2001 From: Ehsan Date: Sun, 8 Nov 2026 17:13:39 +0100 Subject: [PATCH 2/2] fix(ios): always reset anchorPoint on recycle anchorPoint follows transformOrigin, which is sent independently of animate, and _transformOriginX/Y are reset on every recycle. Resetting the anchor only when a transform was animated left a view with a custom transformOrigin that animated something else with a stale anchor on reuse. Adds that case to the issue #72 reproducer. --- example/app/issues/72/index.tsx | 107 +++++++++++++++++++++++++++----- ios/EaseView.mm | 11 ++-- 2 files changed, 95 insertions(+), 23 deletions(-) diff --git a/example/app/issues/72/index.tsx b/example/app/issues/72/index.tsx index bd18e3a..aa34b7a 100644 --- a/example/app/issues/72/index.tsx +++ b/example/app/issues/72/index.tsx @@ -13,27 +13,35 @@ import { EaseView } from 'react-native-ease'; // unclipped with square corners. // // Steps to reproduce: -// 1. A rounded pill clips a larger red square: only a red pill shows. -// 2. Press Unmount, then Mount again (the pill reuses the recycled view). -// 3. Expected: the same red pill, and the mount count goes up. -// Without the fix: the whole 300x300 red square shows, with square corners. +// A. Press Unmount A, then Mount A again (the pill reuses the recycled view). +// Expected: the same rounded red pill. Without the fix: the whole 300x300 +// red square shows, with square corners. +// B. Press Unmount B, then Mount B again. Odd mounts use transformOrigin +// top-left and animate only opacity; even mounts use the default origin and +// scale to 0.6. Expected: the scaled square sits centred in the outline. If +// anchorPoint is not reset on recycle, it scales from the top-left instead. -export default function RecycledClipScreen() { - const [shown, setShown] = useState(true); - const [mounts, setMounts] = useState(1); +export default function RecycledViewScreen() { + const [clipShown, setClipShown] = useState(true); + const [clipMounts, setClipMounts] = useState(1); + const [anchorShown, setAnchorShown] = useState(true); + const [anchorMounts, setAnchorMounts] = useState(1); + const topLeftOrigin = anchorMounts % 2 === 1; return ( - Press Unmount, then Mount again. Only a rounded red pill must show, not - a red square. Mount #{mounts}. + Unmount and mount each case again. A must stay a rounded pill. B must + stay centred in its outline on even mounts. github.com/appandflow/react-native-ease/issues/72 + + A — clipping, mount #{clipMounts} - {shown && ( + {clipShown && ( { - if (!shown) setMounts((n) => n + 1); - setShown((s) => !s); + if (!clipShown) setClipMounts((n) => n + 1); + setClipShown((s) => !s); + }} + > + + {clipShown ? 'Unmount A' : 'Mount A again'} + + + + + B — anchor, mount #{anchorMounts} ( + {topLeftOrigin ? 'origin top-left, opacity' : 'default origin, scale'}) + + + + + {anchorShown && + (topLeftOrigin ? ( + + ) : ( + + ))} + + + { + if (!anchorShown) setAnchorMounts((n) => n + 1); + setAnchorShown((s) => !s); }} > - {shown ? 'Unmount' : 'Mount again'} + {anchorShown ? 'Unmount B' : 'Mount B again'} @@ -73,13 +117,19 @@ const styles = StyleSheet.create({ link: { color: '#6666aa', fontSize: 12, - marginBottom: 28, + marginBottom: 20, + }, + cardTitle: { + fontSize: 15, + fontWeight: '600', + color: '#e0e0ff', + marginBottom: 8, }, stage: { - height: 160, + height: 130, alignItems: 'center', justifyContent: 'center', - marginBottom: 28, + marginBottom: 12, }, pill: { width: 160, @@ -93,12 +143,37 @@ const styles = StyleSheet.create({ height: 300, backgroundColor: '#e05555', }, + outline: { + width: 120, + height: 120, + borderWidth: 1, + borderStyle: 'dashed', + borderColor: '#6666aa', + alignItems: 'center', + justifyContent: 'center', + }, + expected: { + position: 'absolute', + width: 72, + height: 72, + borderWidth: 1, + borderColor: '#5fd38d', + }, + square: { + width: 120, + height: 120, + backgroundColor: '#4a90d9', + }, + squareFaint: { + backgroundColor: '#4a90d966', + }, button: { alignSelf: 'center', paddingHorizontal: 20, paddingVertical: 12, borderRadius: 10, backgroundColor: '#16213e', + marginBottom: 24, }, buttonText: { color: '#e0e0ff', diff --git a/ios/EaseView.mm b/ios/EaseView.mm index bd98dbc..7cdc5bc 100644 --- a/ios/EaseView.mm +++ b/ios/EaseView.mm @@ -1664,16 +1664,13 @@ - (void)prepareForRecycle { _transformOriginX = 0.5; _transformOriginY = 0.5; _transformPerspective = 1280.0; - // Reset only what this view animated. RCTViewComponentView keeps _props - // across recycling and diffs the next props against it, so a style value it - // applied (overflow, borderRadius, backgroundColor, ...) is not applied again - // when the next use has the same value. Resetting those layer properties - // here left a reused view unclipped with square corners. Animated properties - // belong to this view and are set again by the next first-mount update. + // Reset only what this view animated: RCTViewComponentView keeps _props + // across recycling and won't re-apply an unchanged style value (overflow, + // borderRadius, ...). anchorPoint is ours (transformOrigin), so always reset. const auto &oldProps = *std::static_pointer_cast(_props); const int mask = oldProps.animatedProperties; + self.layer.anchorPoint = CGPointMake(0.5, 0.5); if (mask & kMaskAnyTransform) { - self.layer.anchorPoint = CGPointMake(0.5, 0.5); self.layer.transform = CATransform3DIdentity; } if (mask & kMaskOpacity) {