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

Doesn't play nice with styled components #25

Closed
sonaye opened this issue May 11, 2018 · 8 comments
Closed

Doesn't play nice with styled components #25

sonaye opened this issue May 11, 2018 · 8 comments

Comments

@sonaye
Copy link
Contributor

sonaye commented May 11, 2018

I found that this library renders glitchy animations when using styled-components, glamorous-native or a custom styled components API, switching to the typical way of writing styles in RN fixes things. I wrote a light custom styled-components-like function to do some debugging.

kapture 2018-05-11 at 14 21 48

Top: Not using styled components.
Bottom: Using styled components.

Code to reproduce available here.

@chrfalch
Copy link
Contributor

I think I know what's going on here... The interpolator system needs to get information about the items from somewhere, and that somewhere is the style property. When providing function based components the style is not available until the item function has been called. This will result in the issue you are having with the background color.

The other thing the example shows is the strange size transition - that should not look like what you see and I'll take a look at it and see what if I can find out what's going on.

@chrfalch
Copy link
Contributor

If you add the following style to the outer container view, the size transition seems to be working:

<View style={{ flex: 1, justifyContent: 'flex-start', alignItems: 'flex-start' }}>

The problem seems to be that the UIManager.measureInWindow function returns the wrong size for the elements without this style. This might have something to do with the createAnimatedWrapper function I'm using and I'll keep on investigating this.

@dcvz
Copy link
Contributor

dcvz commented May 12, 2018

I've seen similar things happen when you have items that take up percentage width. My fix has usually been to insert an invisible item that has the window width, but it'd be great for the library's <Transition /> to be able to replicate the parent's window.

@sonaye
Copy link
Contributor Author

sonaye commented May 12, 2018

The interpolator system needs to get information about the items from somewhere, and that somewhere is the style property

@chrfalch This explains it. Maybe we can fix this by adding a defaultStyle prop to <Transition /> which -if provided- forwards the styles to the interpolator. Then as a user I can add a HOC that injects defaultStyle to every styled components used (since this is left to the user, adding a defaultStyle prop is enough).

@sonaye
Copy link
Contributor Author

sonaye commented May 12, 2018

@dcvz In general, animations in React Native don't work well with percentages (typically they would throw).

@sonaye
Copy link
Contributor Author

sonaye commented May 17, 2018

Revisiting this again I think supporting styled components is not an essential thing to have, I like the direction the development is going, let's keep it that way for now.

@sonaye sonaye closed this as completed May 17, 2018
@chrfalch
Copy link
Contributor

@sonaye The last version in develop now supports retrieving rendered props from components like the one you wrote - just mentioning it you'd like to try :-) Haven't released it yet.

@lXSPandora
Copy link

Can we re-open this because still not working nice with styled components @sonaye @chrfalch

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

No branches or pull requests

4 participants