Jump to content
GreenSock

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

HELP - transformOrigin/smoothOrigin problem

Recommended Posts

hello and thanks in advance,

 

i'm having trouble with transformOrigin/smoothOrigin (see codepen).  it's not functioning as expected.  the block should rotate as if it's rolling on the ground (as much as a rectangular block would roll).  basically, trying to do something like this demo: 

See the Pen 053d0ee8da31db3bdca1a4531e0628ee by GreenSock (@GreenSock) on CodePen

 

what am i doing wrong?

 

thanks!

See the Pen ojEBWY by anon (@anon) on CodePen

Link to post
Share on other sites

Hi unpaidintern :),

 

I believe smoothOrigin is for SVG only at the moment. It isn't going to work on regular DOM elements. If you look at this page: http://greensock.com/svg-tips - at the bottom Jack mentions possibly adding smoothOrigin for DOM elements in the future, but I don't believe anything is available at this time.

 

If I'm wrong about that, I'm sure someone else will correct me.

 

Here is a revised version of your pen with the rectangle rotating correctly. :)

 

See the Pen ZbrLPG by PointC (@PointC) on CodePen

  • Like 2
Link to post
Share on other sites

If it's supposed to be rolling on the ground then you should first set the CSS up to position the rectangle on the bottom of the viewport:

#ban-roller_wrapper {
…
bottom: 0;
…
}

Also I believe this approach you are using in the JS is meant for SVG and not a div, but maybe someone else can correct me If I'm mistaken.

Link to post
Share on other sites

You guys are exactly correct about smoothOrigin being only for SVG. Good job :)

Link to post
Share on other sites

well, that explains it!  doh.

 

i ended up doing this:  

See the Pen avqpEN by wilbsy (@wilbsy) on CodePen

 

it's pretty hacky, but basically works...  however, it sometimes shows a flash of the box in the wrong place (fairly random - seems like it renders for a split second before the props are set - sometimes it runs with no issue at all).  any ideas on how to smooth this out?

 

thanks!

Link to post
Share on other sites

I wasn't able to see any glitches at all. Even tried my iPad. Not quite sure what to advise. 

 

By the way, do you know about TimelineLite and TimelineMax? You could make your code a lot more concise with those, and you wouldn't have to manage that "delay" variable. 

var tl = new TimelineLite();
tl.to(...)
  .to(...)
  .to(...)

That would sequence things. And if you want to drop 2 things in at a time, you can just use labels:

tl.to(..., "frame1")
  .to(..., "frame1")
  .to(..., "frame2")
  .to(..., "frame2")

It would also allow you to control the entire sequence as a whole. You could pause()/resume()/timeScale() or whatever. 

Link to post
Share on other sites

Any news to getting SmoothOrigin working for DOM elements? I could really really use that!

Or perhaps help me understand how to handle the transform matrix and I could code it. I couldn't find anything on Google and this SmoothOrigin is exactly what I need if it worked for DOM elements.

Thanks,

Jason

Link to post
Share on other sites

Sorry, @Redhawk but svgOrigin is not available for regular DOM elements. 

 

Maybe if you created a new topic and included a reduced test case in codepen showing that demonstrated what your goal is, we might be able to help you with some other idea. 

  • Like 3
Link to post
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.

×