Jump to content
Search Community

Dynamic transformOrigin?

joeworkman test
Moderator Tag

Recommended Posts

I am using transformOrigin and would love to have the Z part of that be dynamic. I need to it either be 50% of the width or height, depending on what I am animating. Is there any way to do this without watching for browser resize events and update the animation based on the size of the element?

 

Here is an example that I am using. I would like that `-25px` part dynamic somehow. 

 

gsap.set(".qf-card", {
    transformOrigin: "50% 50% -25px"
});

 

See the Pen bGpyzRy by joeworkman (@joeworkman) on CodePen

Link to comment
Share on other sites

Hm, I'm not quite sure I understand the question - when exactly would you want that value to change? Like...wouldn't you just be able to add a gsap.set() call wherever you're making your other "dynamic" changes? What would trigger a change? You mentioned the size of the element - how would that size change (what outside force is acting upon it)? 

  • Like 1
Link to comment
Share on other sites

I am thinking in more of a responsive setting where the animated element is not fixed width. When the browser gets resized, the animated element could have its size be different. This means that the transformOrigin property would need to be updated. 

 

Does that make sense?

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