Skip to content

feat: Add support for transition shorthand #6968

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
merged 6 commits into from
Feb 11, 2025
Merged

Conversation

tomekzaw
Copy link
Member

@tomekzaw tomekzaw commented Jan 31, 2025

Summary

This PR adds support for CSS transition property shorthand to create transitions with a single line of code using just a single property.

Test plan

Source code
import React, { useReducer } from 'react';
import { Button, StyleSheet, View } from 'react-native';
import Animated, { steps } from 'react-native-reanimated';

export default function EmptyExample() {
  const [state, toggleState] = useReducer((s) => !s, false);

  return (
    <View style={styles.container}>
      <Animated.View
        style={{
          width: state ? 200 : 100,
          height: state ? 200 : 100,
          transform: [{ rotate: state ? '45deg' : '0deg' }],
          transitionTimingFunction: steps(5), // overridden by the shorthand
          backgroundColor: 'red',
          transition:
            'all 0.5s 0.1s steps(4), height 1s 1.5s ease-out, boxShadow 2s ease-in',
          transitionDuration: 1000, // overrides the shorthand
        }}
      />
      <Button title="Toggle width" onPress={toggleState} />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },
});

@MatiPl01 MatiPl01 force-pushed the parse-transition-shorthand branch from 1f3b8fc to 7665c15 Compare February 4, 2025 23:41
@MatiPl01 MatiPl01 force-pushed the parse-transition-shorthand branch from 15b0c26 to ee85e68 Compare February 5, 2025 14:30
@MatiPl01 MatiPl01 changed the title Parse transition shorthand feat: Add support for transition shorthand Feb 5, 2025
@MatiPl01 MatiPl01 marked this pull request as ready for review February 5, 2025 15:06
@MatiPl01 MatiPl01 added this pull request to the merge queue Feb 11, 2025
Merged via the queue into main with commit 6e22ba6 Feb 11, 2025
9 checks passed
@MatiPl01 MatiPl01 deleted the parse-transition-shorthand branch February 11, 2025 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants