Jump to content
Search Community

›Dynamic‹ Tween

leander test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts



I´m new to gsap. And I do not know any solution.


Here is my Code:


var mc_new = "acco" + btnId;

TweenLite.fromTo(mc_new, 0.5, {opacity:0.5}, {opacity:1.0, ease:Sine.easeInOut, onComplete:callTab});


How do I make this Tween ›Dynamic‹. Thx for your Help :)

Link to comment
Share on other sites

Hi and welcome to the forums.


Well the best way to do it like that is through a function, you create a generic function and then you call it indicating the element you want the function to tween, something like this:

var yourElement = document.getElementById("element1ID"),
    anotherElement = document.getElementById("element2ID"),;

//Create the generic function
function dynTween(element)
    TweenLite.fromTo(element, 0.5, {opacity:0.5},{opacity:1, ease:Sine.easeInOut, onComplete:callTab});

//Call the function for the specific element

Call the function for another element

And of course you can call that function no every event you need, for example button click, mouse over, mouse out, focus, blur, etc.


Hope this helps,



  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...