From 5338988a7c3f37927b2776653d3774f841027d11 Mon Sep 17 00:00:00 2001 From: Janic Duplessis Date: Sat, 14 Mar 2026 19:22:35 -0400 Subject: [PATCH 1/5] feat: add staggered cards demo to example app Add a new demo showcasing staggered enter animations with 4 colored cards that fade in and slide up sequentially using JS-side timeouts. Includes a Replay button to remount and replay the animation. --- example/src/App.tsx | 77 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) diff --git a/example/src/App.tsx b/example/src/App.tsx index 8f4693f..aef9167 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -1,4 +1,4 @@ -import { useState, useEffect } from 'react'; +import { useState, useEffect, useCallback } from 'react'; import { View, StyleSheet, @@ -421,6 +421,64 @@ function StyleReRenderDemo() { ); } +const STAGGER_CARDS = [ + { color: '#4a90d9', label: 'Card 1', delay: 0 }, + { color: '#e06c75', label: 'Card 2', delay: 150 }, + { color: '#98c379', label: 'Card 3', delay: 300 }, + { color: '#d19a66', label: 'Card 4', delay: 450 }, +]; + +function StaggeredCardsDemo() { + const [mountKey, setMountKey] = useState(0); + + return ( +
+ +
+ ); +} + +function StaggeredCards() { + const [visible, setVisible] = useState(() => + STAGGER_CARDS.map(() => false), + ); + + const showCard = useCallback((index: number) => { + setVisible((prev) => { + const next = [...prev]; + next[index] = true; + return next; + }); + }, []); + + useEffect(() => { + const timers = STAGGER_CARDS.map((card, i) => + setTimeout(() => showCard(i), card.delay), + ); + return () => timers.forEach(clearTimeout); + }, [showCard]); + + return ( + + {STAGGER_CARDS.map((card, i) => ( + + {card.label} + + ))} + + ); +} + function DemosScreen() { return ( @@ -446,6 +504,7 @@ function DemosScreen() { + ); } @@ -606,6 +665,22 @@ const styles = StyleSheet.create({ fontSize: 13, fontWeight: '700', }, + staggerRow: { + flexDirection: 'row', + gap: 10, + }, + staggerCard: { + flex: 1, + height: 100, + borderRadius: 12, + alignItems: 'center', + justifyContent: 'center', + }, + staggerCardText: { + color: '#fff', + fontSize: 13, + fontWeight: '700', + }, styledCard: { opacity: 0.6, backgroundColor: '#2a2a4a', From 516f983726733a930eb84b65528b5a4a7d5f17aa Mon Sep 17 00:00:00 2001 From: Janic Duplessis Date: Sat, 14 Mar 2026 19:38:46 -0400 Subject: [PATCH 2/5] feat: add delay prop to timing transitions and use in staggered cards demo Add native delay support (transitionDelay) to timing animations on both iOS (CAAnimation beginTime) and Android (Animator startDelay). Update the staggered cards demo to use the native delay prop instead of JS setTimeout. --- android/src/main/java/com/ease/EaseView.kt | 4 +++ .../src/main/java/com/ease/EaseViewManager.kt | 5 +++ example/ios/Podfile.lock | 8 ++--- example/src/App.tsx | 33 +++++-------------- ios/EaseView.mm | 4 +++ src/EaseView.tsx | 3 ++ src/EaseViewNativeComponent.ts | 1 + src/__tests__/EaseView.test.tsx | 15 +++++++++ src/types.ts | 2 ++ 9 files changed, 46 insertions(+), 29 deletions(-) diff --git a/android/src/main/java/com/ease/EaseView.kt b/android/src/main/java/com/ease/EaseView.kt index e36e959..ea448bf 100644 --- a/android/src/main/java/com/ease/EaseView.kt +++ b/android/src/main/java/com/ease/EaseView.kt @@ -41,6 +41,7 @@ class EaseView(context: Context) : ReactViewGroup(context) { var transitionDamping: Float = 15.0f var transitionStiffness: Float = 120.0f var transitionMass: Float = 1.0f + var transitionDelay: Int = 0 var transitionLoop: String = "none" // --- Transform origin (0–1 fractions) --- @@ -384,6 +385,7 @@ class EaseView(context: Context) : ReactViewGroup(context) { val animator = ValueAnimator.ofArgb(fromColor, toColor).apply { duration = transitionDuration.toLong() + if (transitionDelay > 0) startDelay = transitionDelay.toLong() interpolator = PathInterpolator( transitionEasingBezier[0], transitionEasingBezier[1], transitionEasingBezier[2], transitionEasingBezier[3] @@ -443,6 +445,7 @@ class EaseView(context: Context) : ReactViewGroup(context) { val animator = ObjectAnimator.ofFloat(this, propertyName, fromValue, toValue).apply { duration = transitionDuration.toLong() + if (transitionDelay > 0) startDelay = transitionDelay.toLong() interpolator = PathInterpolator( transitionEasingBezier[0], transitionEasingBezier[1], transitionEasingBezier[2], transitionEasingBezier[3] @@ -613,6 +616,7 @@ class EaseView(context: Context) : ReactViewGroup(context) { applyBackgroundColor(Color.TRANSPARENT) isFirstMount = true + transitionDelay = 0 transitionLoop = "none" } } diff --git a/android/src/main/java/com/ease/EaseViewManager.kt b/android/src/main/java/com/ease/EaseViewManager.kt index 33b36c0..a8be942 100644 --- a/android/src/main/java/com/ease/EaseViewManager.kt +++ b/android/src/main/java/com/ease/EaseViewManager.kt @@ -153,6 +153,11 @@ class EaseViewManager : ReactViewManager() { } } + @ReactProp(name = "transitionDelay", defaultInt = 0) + fun setTransitionDelay(view: EaseView, value: Int) { + view.transitionDelay = value + } + @ReactProp(name = "transitionDamping", defaultFloat = 15f) fun setTransitionDamping(view: EaseView, value: Float) { view.transitionDamping = value diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index df14d76..4741e69 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1,7 +1,7 @@ PODS: - boost (1.84.0) - DoubleConversion (1.1.6) - - Ease (0.1.0): + - Ease (0.2.0): - boost - DoubleConversion - fast_float @@ -3005,12 +3005,12 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: boost: 7e761d76ca2ce687f7cc98e698152abd03a18f90 DoubleConversion: cb417026b2400c8f53ae97020b2be961b59470cb - Ease: e0e726adb99768bed143604b0b07661422921519 + Ease: 1926ac476b99e4d4bbe830c0f8f7edf5d3990cdb fast_float: b32c788ed9c6a8c584d114d0047beda9664e7cc6 FBLazyVector: a293a88992c4c33f0aee184acab0b64a08ff9458 fmt: a40bb5bd0294ea969aaaba240a927bd33d878cdd glog: 5683914934d5b6e4240e497e0f4a3b42d1854183 - hermes-engine: 3992289ac7e8cd4a0bb902711038e16b94212779 + hermes-engine: c97acd28cdf75b551ac6bd27a54375c20ccc9faa RCT-Folly: 846fda9475e61ec7bcbf8a3fe81edfcaeb090669 RCTDeprecation: 2b70c6e3abe00396cefd8913efbf6a2db01a2b36 RCTRequired: f3540eee8094231581d40c5c6d41b0f170237a81 @@ -3088,4 +3088,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: b945c918935ce26cb0357d98636dc7184bab408a -COCOAPODS: 1.15.2 +COCOAPODS: 1.16.2 diff --git a/example/src/App.tsx b/example/src/App.tsx index aef9167..6c3440a 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -1,4 +1,4 @@ -import { useState, useEffect, useCallback } from 'react'; +import { useState, useEffect } from 'react'; import { View, StyleSheet, @@ -440,36 +440,19 @@ function StaggeredCardsDemo() { } function StaggeredCards() { - const [visible, setVisible] = useState(() => - STAGGER_CARDS.map(() => false), - ); - - const showCard = useCallback((index: number) => { - setVisible((prev) => { - const next = [...prev]; - next[index] = true; - return next; - }); - }, []); - - useEffect(() => { - const timers = STAGGER_CARDS.map((card, i) => - setTimeout(() => showCard(i), card.delay), - ); - return () => timers.forEach(clearTimeout); - }, [showCard]); - return ( - {STAGGER_CARDS.map((card, i) => ( + {STAGGER_CARDS.map((card) => ( {card.label} diff --git a/ios/EaseView.mm b/ios/EaseView.mm index 1151975..46644e3 100644 --- a/ios/EaseView.mm +++ b/ios/EaseView.mm @@ -194,6 +194,10 @@ - (void)applyAnimationForKeyPath:(NSString *)keyPath toValue:toValue props:props loop:loop]; + if (props.transitionDelay > 0) { + animation.beginTime = CACurrentMediaTime() + props.transitionDelay / 1000.0; + animation.fillMode = kCAFillModeBackwards; + } [animation setValue:@(_animationBatchId) forKey:@"easeBatchId"]; animation.delegate = self; [self.layer addAnimation:animation forKey:animationKey]; diff --git a/src/EaseView.tsx b/src/EaseView.tsx index 3568ded..cbbeeb8 100644 --- a/src/EaseView.tsx +++ b/src/EaseView.tsx @@ -217,6 +217,8 @@ export function EaseView({ transition?.type === 'spring' ? transition.stiffness ?? 120 : 120; const transitionMass = transition?.type === 'spring' ? transition.mass ?? 1 : 1; + const transitionDelay = + transition?.type === 'timing' ? transition.delay ?? 0 : 0; const transitionLoop = transition?.type === 'timing' ? transition.loop ?? 'none' : 'none'; @@ -253,6 +255,7 @@ export function EaseView({ transitionType={transitionType} transitionDuration={transitionDuration} transitionEasingBezier={bezier} + transitionDelay={transitionDelay} transitionDamping={transitionDamping} transitionStiffness={transitionStiffness} transitionMass={transitionMass} diff --git a/src/EaseViewNativeComponent.ts b/src/EaseViewNativeComponent.ts index 71d2c73..af4b06a 100644 --- a/src/EaseViewNativeComponent.ts +++ b/src/EaseViewNativeComponent.ts @@ -45,6 +45,7 @@ export interface NativeProps extends ViewProps { transitionDuration?: CodegenTypes.WithDefault; // Easing cubic bezier control points [x1, y1, x2, y2] (default: easeInOut) transitionEasingBezier?: ReadonlyArray; + transitionDelay?: CodegenTypes.WithDefault; transitionDamping?: CodegenTypes.WithDefault; transitionStiffness?: CodegenTypes.WithDefault; transitionMass?: CodegenTypes.WithDefault; diff --git a/src/__tests__/EaseView.test.tsx b/src/__tests__/EaseView.test.tsx index 7d3bc18..21be07a 100644 --- a/src/__tests__/EaseView.test.tsx +++ b/src/__tests__/EaseView.test.tsx @@ -132,6 +132,7 @@ describe('EaseView', () => { const props = getNativeProps(); expect(props.transitionType).toBe('timing'); expect(props.transitionDuration).toBe(300); + expect(props.transitionDelay).toBe(0); expect(props.transitionEasingBezier).toEqual([0.42, 0, 0.58, 1]); expect(props.transitionLoop).toBe('none'); }); @@ -186,6 +187,20 @@ describe('EaseView', () => { expect(getNativeProps().transitionType).toBe('none'); }); + it('passes delay from timing transition', () => { + render( + , + ); + expect(getNativeProps().transitionDelay).toBe(200); + }); + + it('ignores delay for spring transitions', () => { + render( + , + ); + expect(getNativeProps().transitionDelay).toBe(0); + }); + it('passes custom cubic bezier control points', () => { render( Date: Sat, 14 Mar 2026 19:44:48 -0400 Subject: [PATCH 3/5] fix: use setTimeout for stagger instead of native delay prop The delay prop hasn't landed on main yet (PR #2). Use JS-side setTimeout to stagger card visibility until then. --- android/src/main/java/com/ease/EaseView.kt | 4 -- .../src/main/java/com/ease/EaseViewManager.kt | 5 -- example/ios/Podfile.lock | 8 +-- example/src/App.tsx | 51 ++++++++++++++----- ios/EaseView.mm | 4 -- src/EaseView.tsx | 3 -- src/EaseViewNativeComponent.ts | 1 - src/__tests__/EaseView.test.tsx | 15 ------ src/types.ts | 2 - 9 files changed, 42 insertions(+), 51 deletions(-) diff --git a/android/src/main/java/com/ease/EaseView.kt b/android/src/main/java/com/ease/EaseView.kt index ea448bf..e36e959 100644 --- a/android/src/main/java/com/ease/EaseView.kt +++ b/android/src/main/java/com/ease/EaseView.kt @@ -41,7 +41,6 @@ class EaseView(context: Context) : ReactViewGroup(context) { var transitionDamping: Float = 15.0f var transitionStiffness: Float = 120.0f var transitionMass: Float = 1.0f - var transitionDelay: Int = 0 var transitionLoop: String = "none" // --- Transform origin (0–1 fractions) --- @@ -385,7 +384,6 @@ class EaseView(context: Context) : ReactViewGroup(context) { val animator = ValueAnimator.ofArgb(fromColor, toColor).apply { duration = transitionDuration.toLong() - if (transitionDelay > 0) startDelay = transitionDelay.toLong() interpolator = PathInterpolator( transitionEasingBezier[0], transitionEasingBezier[1], transitionEasingBezier[2], transitionEasingBezier[3] @@ -445,7 +443,6 @@ class EaseView(context: Context) : ReactViewGroup(context) { val animator = ObjectAnimator.ofFloat(this, propertyName, fromValue, toValue).apply { duration = transitionDuration.toLong() - if (transitionDelay > 0) startDelay = transitionDelay.toLong() interpolator = PathInterpolator( transitionEasingBezier[0], transitionEasingBezier[1], transitionEasingBezier[2], transitionEasingBezier[3] @@ -616,7 +613,6 @@ class EaseView(context: Context) : ReactViewGroup(context) { applyBackgroundColor(Color.TRANSPARENT) isFirstMount = true - transitionDelay = 0 transitionLoop = "none" } } diff --git a/android/src/main/java/com/ease/EaseViewManager.kt b/android/src/main/java/com/ease/EaseViewManager.kt index a8be942..33b36c0 100644 --- a/android/src/main/java/com/ease/EaseViewManager.kt +++ b/android/src/main/java/com/ease/EaseViewManager.kt @@ -153,11 +153,6 @@ class EaseViewManager : ReactViewManager() { } } - @ReactProp(name = "transitionDelay", defaultInt = 0) - fun setTransitionDelay(view: EaseView, value: Int) { - view.transitionDelay = value - } - @ReactProp(name = "transitionDamping", defaultFloat = 15f) fun setTransitionDamping(view: EaseView, value: Float) { view.transitionDamping = value diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 4741e69..df14d76 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1,7 +1,7 @@ PODS: - boost (1.84.0) - DoubleConversion (1.1.6) - - Ease (0.2.0): + - Ease (0.1.0): - boost - DoubleConversion - fast_float @@ -3005,12 +3005,12 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: boost: 7e761d76ca2ce687f7cc98e698152abd03a18f90 DoubleConversion: cb417026b2400c8f53ae97020b2be961b59470cb - Ease: 1926ac476b99e4d4bbe830c0f8f7edf5d3990cdb + Ease: e0e726adb99768bed143604b0b07661422921519 fast_float: b32c788ed9c6a8c584d114d0047beda9664e7cc6 FBLazyVector: a293a88992c4c33f0aee184acab0b64a08ff9458 fmt: a40bb5bd0294ea969aaaba240a927bd33d878cdd glog: 5683914934d5b6e4240e497e0f4a3b42d1854183 - hermes-engine: c97acd28cdf75b551ac6bd27a54375c20ccc9faa + hermes-engine: 3992289ac7e8cd4a0bb902711038e16b94212779 RCT-Folly: 846fda9475e61ec7bcbf8a3fe81edfcaeb090669 RCTDeprecation: 2b70c6e3abe00396cefd8913efbf6a2db01a2b36 RCTRequired: f3540eee8094231581d40c5c6d41b0f170237a81 @@ -3088,4 +3088,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: b945c918935ce26cb0357d98636dc7184bab408a -COCOAPODS: 1.16.2 +COCOAPODS: 1.15.2 diff --git a/example/src/App.tsx b/example/src/App.tsx index 6c3440a..214dcc3 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -439,24 +439,49 @@ function StaggeredCardsDemo() { ); } +function StaggeredCard({ + color, + label, + delay, +}: { + color: string; + label: string; + delay: number; +}) { + const [visible, setVisible] = useState(delay === 0); + + useEffect(() => { + if (delay > 0) { + const timer = setTimeout(() => setVisible(true), delay); + return () => clearTimeout(timer); + } + return undefined; + }, [delay]); + + return ( + + {label} + + ); +} + function StaggeredCards() { return ( {STAGGER_CARDS.map((card) => ( - - {card.label} - + color={card.color} + label={card.label} + delay={card.delay} + /> ))} ); diff --git a/ios/EaseView.mm b/ios/EaseView.mm index 46644e3..1151975 100644 --- a/ios/EaseView.mm +++ b/ios/EaseView.mm @@ -194,10 +194,6 @@ - (void)applyAnimationForKeyPath:(NSString *)keyPath toValue:toValue props:props loop:loop]; - if (props.transitionDelay > 0) { - animation.beginTime = CACurrentMediaTime() + props.transitionDelay / 1000.0; - animation.fillMode = kCAFillModeBackwards; - } [animation setValue:@(_animationBatchId) forKey:@"easeBatchId"]; animation.delegate = self; [self.layer addAnimation:animation forKey:animationKey]; diff --git a/src/EaseView.tsx b/src/EaseView.tsx index cbbeeb8..3568ded 100644 --- a/src/EaseView.tsx +++ b/src/EaseView.tsx @@ -217,8 +217,6 @@ export function EaseView({ transition?.type === 'spring' ? transition.stiffness ?? 120 : 120; const transitionMass = transition?.type === 'spring' ? transition.mass ?? 1 : 1; - const transitionDelay = - transition?.type === 'timing' ? transition.delay ?? 0 : 0; const transitionLoop = transition?.type === 'timing' ? transition.loop ?? 'none' : 'none'; @@ -255,7 +253,6 @@ export function EaseView({ transitionType={transitionType} transitionDuration={transitionDuration} transitionEasingBezier={bezier} - transitionDelay={transitionDelay} transitionDamping={transitionDamping} transitionStiffness={transitionStiffness} transitionMass={transitionMass} diff --git a/src/EaseViewNativeComponent.ts b/src/EaseViewNativeComponent.ts index af4b06a..71d2c73 100644 --- a/src/EaseViewNativeComponent.ts +++ b/src/EaseViewNativeComponent.ts @@ -45,7 +45,6 @@ export interface NativeProps extends ViewProps { transitionDuration?: CodegenTypes.WithDefault; // Easing cubic bezier control points [x1, y1, x2, y2] (default: easeInOut) transitionEasingBezier?: ReadonlyArray; - transitionDelay?: CodegenTypes.WithDefault; transitionDamping?: CodegenTypes.WithDefault; transitionStiffness?: CodegenTypes.WithDefault; transitionMass?: CodegenTypes.WithDefault; diff --git a/src/__tests__/EaseView.test.tsx b/src/__tests__/EaseView.test.tsx index 21be07a..7d3bc18 100644 --- a/src/__tests__/EaseView.test.tsx +++ b/src/__tests__/EaseView.test.tsx @@ -132,7 +132,6 @@ describe('EaseView', () => { const props = getNativeProps(); expect(props.transitionType).toBe('timing'); expect(props.transitionDuration).toBe(300); - expect(props.transitionDelay).toBe(0); expect(props.transitionEasingBezier).toEqual([0.42, 0, 0.58, 1]); expect(props.transitionLoop).toBe('none'); }); @@ -187,20 +186,6 @@ describe('EaseView', () => { expect(getNativeProps().transitionType).toBe('none'); }); - it('passes delay from timing transition', () => { - render( - , - ); - expect(getNativeProps().transitionDelay).toBe(200); - }); - - it('ignores delay for spring transitions', () => { - render( - , - ); - expect(getNativeProps().transitionDelay).toBe(0); - }); - it('passes custom cubic bezier control points', () => { render( Date: Sat, 14 Mar 2026 21:39:55 -0400 Subject: [PATCH 4/5] feat(example): add start/stop toggle to looping animation demos --- example/src/App.tsx | 44 ++++++++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/example/src/App.tsx b/example/src/App.tsx index 214dcc3..74b5a94 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -45,18 +45,24 @@ function ButtonDemo() { } function BannerDemo() { + const [playing, setPlaying] = useState(true); + return (
@@ -68,24 +74,38 @@ function BannerDemo() { +
); } function PulseDemo() { + const [playing, setPlaying] = useState(true); + return (
+
); } From 5b32bcf2e6cb44a7953c8a71cde7ee0a8763fdff Mon Sep 17 00:00:00 2001 From: Janic Duplessis Date: Sat, 14 Mar 2026 21:40:21 -0400 Subject: [PATCH 5/5] docs: add Android UI automation notes to AGENTS.md --- AGENTS.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/AGENTS.md b/AGENTS.md index 6fda925..5905caf 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -111,3 +111,39 @@ Use conventional commits: `feat:`, `fix:`, `chore:`, `docs:`, etc. - **Spring damping ratio on Android is derived** from `damping`, `stiffness`, and `mass` using: `dampingRatio = damping / (2 * sqrt(stiffness * mass))`. iOS passes these values directly to `CASpringAnimation`. - **Animation batching:** Both platforms track animation batches with a generation ID. When new animations start, any pending old-batch callbacks are fired as interrupted (`finished: false`). - **Loop only works with timing animations**, not springs. Loop requires `initialAnimate` to define the start value. + +## Android UI Automation (agent-device) + +The example app has looping animations (Pulse, Banner) that prevent Android's `uiautomator` from reaching idle state, which breaks `agent-device snapshot` and `find` commands. + +### Workaround +Before using `agent-device snapshot -i` or `find` on Android, either: + +1. **Stop looping animations in the app** — tap the Stop button on Pulse and Banner demos, OR +2. **Disable system animations** (less ideal — also affects recording): + ```bash + adb shell settings put global window_animation_scale 0 + adb shell settings put global transition_animation_scale 0 + adb shell settings put global animator_duration_scale 0 + # Re-enable after: set all back to 1 + ``` + +### iOS +No workaround needed — `agent-device` uses XCTest accessibility on iOS which doesn't require idle state. + +### Android validation flow +```bash +# 1. Open app +agent-device open ease.example --platform android --device "SM G996W" + +# 2. Stop looping demos (tap Stop buttons) or disable system animations + +# 3. Now snapshot works +agent-device snapshot -i + +# 4. Navigate and interact by ref +agent-device press @e9 # e.g. Replay button + +# 5. Screenshot/record +agent-device screenshot /tmp/screenshot.png +```