Skip to content
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

[v3] - Issue with animating Text nodes when using unistyles variants #445

Open
mateioprea opened this issue Dec 16, 2024 · 2 comments
Open
Labels
bug Something isn't working enhancement New feature or request
Milestone

Comments

@mateioprea
Copy link

Description

There seems to be an issue when animating Text (probably other views as well but I only had Texts variants in my app) with unistyles variants.

Steps to Reproduce

  1. Create a Typography component using variants (it only happens when using variants apparently).
import React, {PropsWithChildren} from 'react';
import {Text} from 'react-native';
import {StyleSheet, UnistylesVariants} from 'react-native-unistyles';

interface TypographyProps
  extends PropsWithChildren,
    UnistylesVariants<typeof styles> {}

export default function Typography({children, isBold, size}: TypographyProps) {
  styles.useVariants({
    isBold,
    size,
  });
  return <Text style={styles.title}>{children}</Text>;
}

const styles = StyleSheet.create(theme => ({
  title: {
    color: theme.colors.white,
    variants: {
      isBold: {
        true: {
          fontWeight: 'bold',
        },
      },
      size: {
        extraSmall: {
          fontSize: 14,
        },
        small: {
          fontSize: 16,
        },
        medium: {
          fontSize: 18,
        },
        large: {
          fontSize: 26,
        },
        extraLarge: {
          fontSize: 36,
        },
        default: {
          fontSize: 5,
        },
      },
    },
  },
}));
  1. Try to animate the component in a modal / screen using entering layout animation from reanimated:
<Animated.View
          entering={SlideInRight.springify().mass(1).stiffness(170).damping(26)}
          exiting={SlideOutRight.springify()
            .mass(1)
            .stiffness(170)
            .damping(26)}>
            <Typography size="extraLarge">Test</Typography>
</Animated.View>

You'll see that the animation will have a different place / lags behind. Also, what I found is that its only happening when using variants. If you remove:

 styles.useVariants({
    isBold,
    size,
  });

everything's fine.

Snack or Repository Link (Optional)

No response

Unistyles Version

3.0.0-beta.2

React Native Version

0.76.5

Platforms

iOS

Expo

No

@shahzaib78631
Copy link

+1 Having same issue with animated Views and Texts

@jpudysz
Copy link
Owner

jpudysz commented Dec 16, 2024

Will dedicate one beta to support Reanimated worklets + animations. Thanks for the report

@jpudysz jpudysz added this to the 3.0.0-beta.6 milestone Dec 16, 2024
@jpudysz jpudysz added bug Something isn't working enhancement New feature or request labels Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants