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

How to handle animation style properties correctly #26

Open
kiroukou opened this issue Jan 16, 2019 · 2 comments
Open

How to handle animation style properties correctly #26

kiroukou opened this issue Jan 16, 2019 · 2 comments

Comments

@kiroukou
Copy link
Contributor

I needed to use an animatedValue for some fading animation.

The thing is that the animated component like AnimatedView etc have soem kind of magic to detect the animated properties and optimize it (more that a simple forceUpdate say the documentation).

The need is to use these like so :

<AnimatedView style=${[styles.main, {opacity: anim}]}>

So far, I got it working by 2 ways :
change the externs from (eg ViewStyleProps) :

?opacity:Float

to

?opacity:haxe.extern.EitherType<Float, react.native.api.Animated.AnimatedValue>,

Or by forcing the update myself :

this.state.anim.addListener(onValueChange);

    function onValueChange(v:{value:Float}) {
        this.forceUpdate();
    }

That would be quite inelegant to change all the props so that they can be defined as animatable, so maybe we can do something else ? (abstract somewhere ?)
What's your ideas?
@kevinresol
@back2dos
@zabojad

@kevinresol
Copy link
Member

I think AnimatedView should have its own Props instead of using View's one.

@serjek
Copy link
Contributor

serjek commented Jun 6, 2019

here is one way to get it, a bit dirty but it works: here you have both styles inlined
<AnimatedView style=${cast ([styles.main, {opacity: anim}]:Array<Dynamic>)}>

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

3 participants