Jump to content
Search Community

csshook for tweenmax

samuel 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 am searching for a way to alter css values that are set with tweenmax.


for example:




with jQuery i could do something like this:


    $.cssHooks.marginLeft = {
      get: function( elem, computed, extra ) {
        return $.css( elem, "marginLeft");
      set: function( elem, value) {
        elem.style["marginLeft"] = (parseFloat(value) * 0.5) + "px";
The reason I want to do this is because I have a lot's of tweens and the animation should be adaptive. I could adjust them al by hand but it would be much easier if could add a ratio per breakingpoint. 




Link to comment
Share on other sites

There isn't anything like that currently, but you could certainly create your own plugin to intercept certain properties. There's a template in the plugins directory.


Just curious: is there a reason you don't want to use %-based values? Is it because you want to have hard break points instead of smooth percentages based on any width? I suppose you could wrap things in a div that uses your own break point logic, and inside you could build tweens that use percentages to get that same kind of effect (I think). 

Link to comment
Share on other sites

Thanks, I'll have a look into creating a custom plugin. I'dont wan't to use percentages because of rounding issues. I use a lot of png sprite animations and when I use percentages things tend to cut off or add an extra pixel.

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...