Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
agamemnus

transform: scale is broken when invoked twice.

Recommended Posts

Hello agamemmnus, and Welcome to the GreenSock Forum!

 

Not sure what you mean scale is broke when invoked twice. .. I do see that your are using native javascript to write the inline transform style.. but then you immediately have a tween run after that which would overwrite that line in your for loop.

  • Are you tryng to just set the initial scale value for each element ? ..
  • and then animate each one back to scale factor one?

If so here is your example modified : http://jsfiddle.net/6ojyt5bq/4/

 

I used GSAP set() method instead of using unfiltered_image.style.transform. By using GSAP to set() the CSS properties, you allow it to  handle all the CSS vendor prefixes for the various modern browsers. And then GSAP can keep track of what properties you are animating!

 

You can also use the property scale instead of using transform: scale(1) directly.

 

More info on GSAP TweenMax and  CSSPlugin found here:

If this does not help can you please provide more information on the exact behavior you expect or want?

 

Thanks! :)

Link to comment
Share on other sites

Jonathan: the second time it runs, nothing happens... even in your version.

 

Edit: but it looks like you put the "set" in the wrong place. Your version does run it twice if set is inside the setTimeout function, but why isn't mine running twice?

Link to comment
Share on other sites

Ok, I see what is happening.

 

I set transform to scale, not webkit-transform. However, TweenMax is setting both, and my reset statement is not resetting webkit-transform. Is there a flag I can set to prevent this hidden backwards-compatibility? I understand you want to have backwards compatibility, but to hide it is not the right way.

Link to comment
Share on other sites

What is the behavior you are after? ..

 

Do you just want it to start scaled up and then animate scale down to 1, and then jump back to scale 2.5 and then animate scale back down to 1?

 

http://jsfiddle.net/6ojyt5bq/5/

 

I am still confused on how you want it animated. By using set() im letting GSAP record the values.

 

Because if you just do this:

 

unfiltered_image.style.transform

 

You are changing CSS properties outside of GSAP. So that is why i recommended to use GSAP set() method instead, so GSAP can keep track of your changes, and handle cross browser vendor prefixes for CSS properties.

 

http://caniuse.com/#search=transform

  • Like 1
Link to comment
Share on other sites

No man, I don't want to use GSAP for that. I would like to set the style myself.

 

I want GSAP to not set webkit-transform when I tell it to only set transform. Is that possible?

Link to comment
Share on other sites

The issue is related to this note from the docs greensock.com/docs/#/HTML5/Plugins/CSSPlugin/

By default, GSAP records the transform-related data like scaleX, scaleY, x, y, rotation, etc. so that it persists correctly and works around some browser bugs. If you'd like to clear those values (including the transform applied to the inline style of the element), you can do TweenLite.set(element, {clearProps:"transform"});. If you'd like to force GSAP to re-parse the transform data from the css (rather than use the data it had recorded from previous tweens), you can pass parseTransform:true into the config object.

GSAP tracks the values of transforms internally so setting through style causes a small conflict. If you let GSAP handle all applications of transforms then this shouldn't be an issue. If you want to keep the element.style.transform declarations, then you'll need to add parseTransform:true to your tween.

TweenMax.set(unfiltered_image, { scale: 2.5 });
TweenMax.to(unfiltered_image, 1, { scale: 1, ease: Linear.easeOut });

// or

unfiltered_image.style.transform = "scale(" + initial_scale + ", " + initial_scale + ")";
TweenMax.to(unfiltered_image, 1, { scale: 1, parseTransform: true, ease: Linear.easeOut });

// or

TweenMax.fromTo(unfiltered_image, 1, { scale: 2.5 }, { scale: 1, ease: Linear.easeOut });

And since you're using TweenMax, you could really shorten this by adding a repeat and repeatDelay jsfiddle.net/6ojyt5bq/6/

  • Like 4
Link to comment
Share on other sites

Thanks! Actually I only need to set this once per game... but resetting the game doesn't reset this effect.

Link to comment
Share on other sites

P.S.: is there a global setting for this we can do?

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