Jump to content
Search Community

transformPerspective + fromTo in FireFox

NOEONE 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

Hello NOEONE, and welcome to the GreenSock Forum!

 

I am seeing the element animate with fromTo() .. in Firefox 34 and 35 (Windows 7 PC) .. what Firefox are you seeing this in? .. and is this on a mac or a PC?

 

I also noticed you are using both perspective and transformPerspective on the same element. You wouldn't need perspective on your tween.. since perspective only applies to the elements children, but you have no children...  whereas transformPerspective applies to the element itself.

 

You also might want to use immediateRender:false when using from(), fromTo(), staggerFrom(), or staggerFromTo() tweens, since from() tweens have immediateRender set to true by default.

TweenMax.fromTo(next, 1.5, {
     alpha:0, 
     rotationY: -90, 
     z: 0, 
     rotationX: -180,
     immediateRender: false
    }, {
     alpha:1, 
     x:10, y:150, 
     rotationY: 0, 
     z: 150, 
     rotationX: 0
    }
);

:

Below taken from the fromTo() Docs:

 

NOTE: by default, immediateRender is true in fromTo() tweens, meaning that they immediately render their starting state regardless of any delay that is specified. This is done for convenience because it is often the preferred behavior when setting things up on the screen to animate into place, but you can override this behavior by passingimmediateRender:false in the fromVars or toVars parameter so that it will wait to render the starting values until the tween actually begins.

 

Read more here in the from tween Docs:

 

from() : http://greensock.com/docs/#/HTML5/GSAP/TimelineLite/from/

fromTo() : http://greensock.com/docs/#/HTML5/GSAP/TimelineLite/fromTo/

staggerFrom() : http://greensock.com/docs/#/HTML5/GSAP/TimelineLite/staggerFrom/

staggerFromTo() : http://greensock.com/docs/#/HTML5/GSAP/TimelineLite/staggerFromTo/

 

perspective : https://developer.mozilla.org/en-US/docs/Web/CSS/perspective

transformPerspective : http://css-tricks.com/almanac/properties/p/perspective/

 

Let us know if that helps :)

  • Like 1
Link to comment
Share on other sites

Yeah, I tested in FF35 on a Mac and it worked fine. Kind of strange though that it didn't work in 34. I'm sure we have done plenty of animations like that.

 

One thing I noticed in your pen is that you are just passing the ID into your tweens, but you should use a String selector with the #

 

bad

TweenMax.fromTo(next, 5.5, {alpha:1, rotationY: -90, z: 0, rotationX: -180}, {alpha:1, rotationY: 0, z: 0, rotationX: 0});

 

good (proper string selector)

TweenMax.fromTo("#next",  5.5, {alpha:1, rotationY: -90, z: 0, rotationX: -180}, {alpha:1, rotationY: 0, z: 0, rotationX: 0});

 

Glad its all sorted, and like Jonathan said, come back and ask more questions.

  • Like 2
Link to comment
Share on other sites

NOEONE, The reason divName variable was working is due to the global namespace for id. When you add an id attribute to your DOM elements, the window will load those ID names as global namespaces, part of the DOM window (global-like variables). Its best to avoid that by just explicitly declaring your selector like Carl advised. Even though HTML 4.0 and the new HTML5 specs allow it.. they also advise against it.

  • window[name]
    Returns the indicated element or collection of elements.
    As a general rule, relying on this will lead to brittle code. Which IDs end up mapping to this API can vary over time, as new features are added to the Web platform, for example. Instead of this, use document.getElementById() or document.querySelector().

It is not safe to rely on Global variables, and just set your selectors using document.getElementById() or document.querySelector(). GSAP by default uses document.querySelectorAll(), as of 1.13.1

 

Please see the below for more info:

 

http://www.w3.org/html/wg/drafts/html/master/browsers.html#named-access-on-the-window-object

 

I hope this helps! :)

  • Like 2
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...