azazdeaz / react-gsap-enhancer

Use the full power of React and GSAP together
MIT License
727 stars 38 forks source link

Pass selector to animation function #4

Closed tgienger closed 9 years ago

tgienger commented 9 years ago

So far I'm liking this plugin, but I would like the ability to pass my selector as an argument, either by object or string, to the animation function. This way I can create one animation function to use on multiple targets. Unless of course there's a way to do this that I haven't discovered :)

azazdeaz commented 9 years ago

Hi @tgienger!

Yes, you can pass an object as the second parameter to the addAnimation and the animation source will get it as options:

function animationSource({target, options}) {...}

...
this.addAnimation(animationSource, {foo: this.state.foo})
...

I will document this soon, until that, i made a mini demo on this

tgienger commented 9 years ago

It makes sense looking at it. I tried it but failed because I wasn't using the es6 parameter destructuring properly. Bad on my part, thanks :)

azazdeaz commented 9 years ago

Your welcome! :) I uploaded an other demo that selecting target according the options and i modified the previous one to use only ES5 and JSX. (There should be more demo using plain ES5 i guess)

Thanks for the issue, i'm closing it then!