Skip to content

Commit 01657a4

Browse files
committed
create patch to fix easing animation
1 parent 0a2e659 commit 01657a4

3 files changed

Lines changed: 70 additions & 2 deletions

File tree

patches/react-native-reanimated/details.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,10 @@
1515
- E/App issue: 🛑
1616
- PR Introducing Patch: [NR 0.75 upgrade](https://github.com/Expensify/App/pull/45289)
1717

18+
### [react-native-reanimated+3.19.1+001+correctly-handle-Easing.bezier](react-native-reanimated+3.19.1+002+dontWhitelistTextProp.patch)
19+
20+
- Reason: The Easing.bezier animation doesn't work on web
21+
- Upstream PR/issue: https://github.com/software-mansion/react-native-reanimated/pull/8049
22+
- E/App issue: https://github.com/Expensify/App/pull/63623
23+
- PR Introducing Patch: 🛑
24+
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
diff --git a/node_modules/react-native-reanimated/lib/module/layoutReanimation/web/Easing.web.js b/node_modules/react-native-reanimated/lib/module/layoutReanimation/web/Easing.web.js
2+
index ed0f9d3..6baf136 100644
3+
--- a/node_modules/react-native-reanimated/lib/module/layoutReanimation/web/Easing.web.js
4+
+++ b/node_modules/react-native-reanimated/lib/module/layoutReanimation/web/Easing.web.js
5+
@@ -14,4 +14,18 @@ export const WebEasings = {
6+
export function getEasingByName(easingName) {
7+
return `cubic-bezier(${WebEasings[easingName].toString()})`;
8+
}
9+
-//# sourceMappingURL=Easing.web.js.map
10+
\ No newline at end of file
11+
+export function maybeGetBezierEasing(easing) {
12+
+ if (!('factory' in easing)) {
13+
+ return null;
14+
+ }
15+
+ const easingFactory = easing.factory;
16+
+ if (!('__closure' in easingFactory)) {
17+
+ return null;
18+
+ }
19+
+ const closure = easingFactory.__closure;
20+
+ if (!('Bezier' in closure)) {
21+
+ return null;
22+
+ }
23+
+ return `cubic-bezier(${closure.x1}, ${closure.y1}, ${closure.x2}, ${closure.y2})`;
24+
+}
25+
+
26+
diff --git a/node_modules/react-native-reanimated/lib/module/layoutReanimation/web/componentUtils.js b/node_modules/react-native-reanimated/lib/module/layoutReanimation/web/componentUtils.js
27+
index 7f724c4..ad53a74 100644
28+
--- a/node_modules/react-native-reanimated/lib/module/layoutReanimation/web/componentUtils.js
29+
+++ b/node_modules/react-native-reanimated/lib/module/layoutReanimation/web/componentUtils.js
30+
@@ -10,18 +10,28 @@ import { setElementPosition, snapshots } from "./componentStyle.js";
31+
import { Animations, TransitionType } from "./config.js";
32+
import { TransitionGenerator } from "./createAnimation.js";
33+
import { scheduleAnimationCleanup } from "./domUtils.js";
34+
-import { getEasingByName, WebEasings } from "./Easing.web.js";
35+
+import {
36+
+ getEasingByName,
37+
+ maybeGetBezierEasing,
38+
+ WebEasings
39+
+} from "./Easing.web.js";
40+
import { prepareCurvedTransition } from "./transition/Curved.web.js";
41+
function getEasingFromConfig(config) {
42+
if (!config.easingV) {
43+
return getEasingByName('linear');
44+
}
45+
const easingName = config.easingV[EasingNameSymbol];
46+
- if (!(easingName in WebEasings)) {
47+
- logger.warn(`Selected easing is not currently supported on web.`);
48+
+ if (easingName in WebEasings) {
49+
+ return getEasingByName(easingName);
50+
+ }
51+
+ const bezierEasing = maybeGetBezierEasing(config.easingV);
52+
+ if (!bezierEasing) {
53+
+ logger.warn(
54+
+ `Selected easing is not currently supported on web. Using linear easing instead.`
55+
+ );
56+
return getEasingByName('linear');
57+
}
58+
- return getEasingByName(easingName);
59+
+ return bezierEasing;
60+
}
61+
function getRandomDelay(maxDelay = 1000) {
62+
return Math.floor(Math.random() * (maxDelay + 1)) / 1000;

src/CONST/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6273,8 +6273,7 @@ const CONST = {
62736273

62746274
SEARCH: {
62756275
RESULTS_PAGE_SIZE: 50,
6276-
EXITING_ANIMATION_DURATION: 300,
6277-
LAYOUT_ANIMATION_DURATION: 375,
6276+
EXITING_ANIMATION_DURATION: 200,
62786277
DATA_TYPES: {
62796278
EXPENSE: 'expense',
62806279
INVOICE: 'invoice',

0 commit comments

Comments
 (0)