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

Add SVG color properties to list of color attributes to parse #6567

Merged
merged 1 commit into from
Oct 3, 2024

Conversation

jakex7
Copy link
Member

@jakex7 jakex7 commented Oct 3, 2024

Summary

This PR will significantly enhance the developer experience when animating SVGs, as with these changes, the SVGAdapter is no longer required (at least for animating colors). It's related to the following PR: software-mansion/react-native-svg#2471

Test plan

At this point, the changes will not impact the current behavior and need to be tested within the react-native-svg repository until the release. Once the RNSVG release is out, I will add an example to the Reanimated repository.

@jakex7 jakex7 requested a review from tomekzaw October 3, 2024 11:00
Copy link
Member

@tomekzaw tomekzaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! 🫡

@tomekzaw tomekzaw added this pull request to the merge queue Oct 3, 2024
Merged via the queue into main with commit e20b87c Oct 3, 2024
10 checks passed
@tomekzaw tomekzaw deleted the @jakex7/parseSvgColorProperties branch October 3, 2024 11:59
@tjzel
Copy link
Collaborator

tjzel commented Oct 3, 2024

@jakex7 is this change backwards compatible? Reanimated 3.16 will support at least React Native 0.74. Will it work with all react-native-svg versions compatible with React Native 0.74? You said the current changes don't affect current behavior - how comes this will change once new RNSVG is out?

@jakex7
Copy link
Member Author

jakex7 commented Oct 3, 2024

@jakex7 is this change backwards compatible? Reanimated 3.16 will support at least React Native 0.74. Will it work with all react-native-svg versions compatible with React Native 0.74?

Yes, it is. It will support all compatible react-native and react-native-svg versions.
Currently, it's required to write custom createAnimatedPropAdapter like this:

const adapter = createAnimatedPropAdapter(
  props => {
    if (Object.keys(props).includes('fill')) {
      props.fill = {type: 0, payload: processColor(props.fill)};
    }
  },
  ['fill'],
);

These changes won't affect the users with custom adapters, as their colors will be passed as ColorStruct anyway.

You said the current changes don't affect current behavior - how comes this will change once new RNSVG is out?

New version of RNSVG will support ColorValue type in addition to custom ColorStruct on 'color', 'fill', 'floodColor', 'lightingColor', 'stopColor', 'stroke'

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.

3 participants