Skip to content

Conversation

MatiPl01
Copy link
Member

@MatiPl01 MatiPl01 commented Sep 2, 2025

Summary

This PR finally adds the integration of 2D and 3D transform matrix in transforms interpolation. The 2D matrix is used when possible to optimize interpolation. If the user uses a transformation that requires a 3D space (like x, y rotation or perspective), the 3D matrix is used instead. 2D transform matrix is automatically converted to the 3D transform matrix when needed.

Test plan

Code snippet
import { useState } from 'react';
import type { ViewStyle } from 'react-native';
import { StyleSheet, View } from 'react-native';
import Animated from 'react-native-reanimated';

import { Button, Screen } from '@/apps/css/components';

const transitionStyles: Array<ViewStyle> = [
  {
    transform: [{ rotate: '45deg' }, { skewX: '45deg' }],
  },
  {
    transform: [{ translateY: 200 }, { rotate: '45deg' }, { scale: 2 }],
  },
  {
    transform: [{ rotate: '45deg' }, { translateY: 150 }],
    width: 200,
  },
];

export default function Playground() {
  const [state, setState] = useState(0);
  const stateToStyle = (num: number) => {
    return transitionStyles[num % transitionStyles.length];
  };

  return (
    <Screen>
      <View style={styles.container}>
        <Button
          title="Change state"
          onPress={() => {
            setState(state + 1);
          }}
        />
        <Animated.View
          style={[
            {
              backgroundColor: 'red',
              height: 65,
              marginTop: 60,
              transitionDuration: '0.5s',
              width: 65,
            },
            stateToStyle(state),
          ]}
        />
      </View>
    </Screen>
  );
}

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

@MatiPl01 MatiPl01 self-assigned this Sep 2, 2025
@MatiPl01 MatiPl01 changed the title Working on 3D and 2D matrix integration feat: 3D and 2D CSS transform matrix integration Sep 3, 2025
@MatiPl01 MatiPl01 force-pushed the @matipl01/combining-2d-and-3d-transforms branch from 7072987 to 67247e8 Compare September 5, 2025 13:51
@MatiPl01 MatiPl01 changed the base branch from main to @matipl01/some-css-improvements September 17, 2025 17:19
@MatiPl01 MatiPl01 requested a review from piaskowyk September 17, 2025 17:25
@MatiPl01 MatiPl01 marked this pull request as ready for review September 17, 2025 17:25
@MatiPl01 MatiPl01 force-pushed the @matipl01/some-css-improvements branch from f690fb3 to 1eac7a6 Compare September 19, 2025 10:31
@MatiPl01 MatiPl01 changed the base branch from @matipl01/some-css-improvements to main September 19, 2025 16:11
@MatiPl01 MatiPl01 changed the base branch from main to @matipl01/some-css-improvements September 19, 2025 16:11
@MatiPl01 MatiPl01 force-pushed the @matipl01/combining-2d-and-3d-transforms branch from a7dab24 to d1e5abf Compare September 19, 2025 16:12
github-merge-queue bot pushed a commit that referenced this pull request Sep 22, 2025
## Summary

This PR contains some code extracted from the #8195 that can be added
separately in order not to add too much complexity to the already large
PR.
Base automatically changed from @matipl01/some-css-improvements to main September 22, 2025 08:16
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.

1 participant