Skip to content

fix: Reduce Motions + animation callbacks - #8142

Merged
piaskowyk merged 1 commit into
mainfrom
@piaskowyk/reduce-motion-callbacks
Aug 26, 2025
Merged

piaskowyk merged 1 commit into
mainfrom
@piaskowyk/reduce-motion-callbacks

Conversation

@piaskowyk

@piaskowyk piaskowyk commented Aug 26, 2025 •

Copy link
Copy Markdown
Member

Summary

This PR fixes #8046.
With the previous approach introduced in #6864, we didn't configure layout animations when reduce motion was enabled, which was problematic because in this case, callbacks weren't called at the end of animations. This PR restores layout animation configuration while still respecting the reduce motion config.

I've tested these changes against #6864 and #7812, and both are working properly.

Screen.Recording.2025-08-26.at.09.34.36.mov

Test plan

code
import React from 'react';
import { Button, StyleSheet, View } from 'react-native';
import Animated, {
  BounceInLeft,
  FadeOutRight,
  Layout,
} from 'react-native-reanimated';

export default function BasicLayoutAnimation() {
  const [state, setState] = React.useState(false);
  const [visible, setVisible] = React.useState(true);

  return (
    <View style={styles.container}>
      <Button onPress={() => setVisible(!visible)} title="Create/Remove" />
      <Button onPress={() => setState(!state)} title="Update" />
      {visible && (
        <Animated.View
          entering={BounceInLeft.withCallback(() => console.log('entering'))}
          layout={Layout.springify().withCallback(() => console.log('layout'))}
          exiting={FadeOutRight.duration(500).withCallback(() => console.log('exiting'))}
          style={[
            styles.box,
            {
              marginLeft: state ? 200 : 0,
              backgroundColor: state ? 'red' : 'blue',
            },
          ]}
        />
      )}
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    marginTop: 300,
  },
  box: {
    width: 100,
    height: 100,
  },
});

@piaskowyk
piaskowyk added this pull request to the merge queue Aug 26, 2025
Merged via the queue into main with commit ffb6e89 Aug 26, 2025
@piaskowyk
piaskowyk deleted the @piaskowyk/reduce-motion-callbacks branch August 26, 2025 12:54
MatiPl01 pushed a commit that referenced this pull request Aug 26, 2025
## Summary

This PR fixes
#8046.
With the previous approach introduced in
#6864,
we didn't configure layout animations when reduce motion was enabled,
which was problematic because in this case, callbacks weren't called at
the end of animations. This PR restores layout animation configuration
while still respecting the reduce motion config.

I've tested these changes against
#6864
and
#7812,
and both are working properly.


https://github.com/user-attachments/assets/48a6e913-b53e-41e8-8a15-842d2ab7511a

## Test plan

<details>
<summary>code</summary>

```js
import React from 'react';
import { Button, StyleSheet, View } from 'react-native';
import Animated, {
  BounceInLeft,
  FadeOutRight,
  Layout,
} from 'react-native-reanimated';

export default function BasicLayoutAnimation() {
  const [state, setState] = React.useState(false);
  const [visible, setVisible] = React.useState(true);

  return (
    <View style={styles.container}>
      <Button onPress={() => setVisible(!visible)} title="Create/Remove" />
      <Button onPress={() => setState(!state)} title="Update" />
      {visible && (
        <Animated.View
          entering={BounceInLeft.withCallback(() => console.log('entering'))}
          layout={Layout.springify().withCallback(() => console.log('layout'))}
          exiting={FadeOutRight.duration(500).withCallback(() => console.log('exiting'))}
          style={[
            styles.box,
            {
              marginLeft: state ? 200 : 0,
              backgroundColor: state ? 'red' : 'blue',
            },
          ]}
        />
      )}
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    marginTop: 300,
  },
  box: {
    width: 100,
    height: 100,
  },
});

```

</details>
MatiPl01 added a commit that referenced this pull request Aug 27, 2025
Cherry-pick of the #8142

Co-authored-by: Krzysztof Piaskowy <krzysztof.piaskowy@swmansion.com>
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.

Entering animations not completing if 'Reduce Motion' accessibility setting is on (v3.19)

2 participants