Skip to content

(cherry-pick) fix: Keyframe LA easing not working properly on web #7991

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

MatiPl01
Copy link
Member

@MatiPl01 MatiPl01 commented Aug 4, 2025

Cherry-pick of the #7978

## Summary

Fixes: #7950

This PR fixes the problem with easings configured via the custom
`Keyframe` layout animation on web. The problem results from the adopted
convention in which we expect the keyframe easing to be defined in the
second keyframe of the keyframes pair between which the easing should be
applied.

This is different from how CSS animations work and slightly confusing
but, since changing this behavior will introduce a breaking change, I
decide to just adjust the web implementation to shift keyframe easings
one keyframe before, which in result makes it possible to create a valid
CSS animation from out LA `Keyframe` object.

## Test example

Before this PR the custom easing was not applied and the animation
progressed with a default easing.

| Before | After |
|-|-|
| <video
src="https://github.com/user-attachments/assets/15629df8-f9d1-4b34-b119-eb325b30ee97"
/> | <video
src="https://github.com/user-attachments/assets/a7145b3b-cefa-4dbb-8eb5-a0454bb0346b"
/> |

<details>
<summary>Source code</summary>

```tsx
import React from 'react';
import { Easing, StyleSheet, Text } from 'react-native';
import Animated, { Keyframe } from 'react-native-reanimated';

export default function EmptyExample() {
  const keyframe = new Keyframe({
    0: {
      transform: [{ translateY: `100%` }],
    },
    100: {
      transform: [{ translateY: `0%` }],
      easing: Easing.exp,
    },
  });

  return (
    <Animated.View entering={keyframe.duration(1000)} style={styles.box}>
      <Text>Some text</Text>
    </Animated.View>
  );
}

const styles = StyleSheet.create({
  box: {
    width: 100,
    height: 100,
    backgroundColor: 'red',
  },
});
```

</details>
@MatiPl01 MatiPl01 changed the base branch from main to 4.0-stable August 4, 2025 11:02
@MatiPl01 MatiPl01 self-assigned this Aug 4, 2025
@MatiPl01 MatiPl01 mentioned this pull request Aug 4, 2025
15 tasks
@MatiPl01 MatiPl01 requested a review from m-bert August 4, 2025 12:02
@MatiPl01 MatiPl01 merged commit 1499cc1 into 4.0-stable Aug 4, 2025
21 checks passed
@MatiPl01 MatiPl01 deleted the @matipl01/cherry-pick/fix-web-LA-keyframe-easings branch August 4, 2025 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants