wpsoul Posted April 17, 2022 Share Posted April 17, 2022 I want to make real 3d look. If I add perspective value to parent container, it looks not proper because perspective added to whole block with all childrens. But when I add transformPerspective option according to documentation, I see strange jump in end of animation See the Pen YzYdyEa by igor-sunz (@igor-sunz) on CodePen Link to comment Share on other sites More sharing options...
akapowl Posted April 17, 2022 Share Posted April 17, 2022 Hello @wpsoul 36 minutes ago, wpsoul said: But when I add transformPerspective option according to documentation, I see strange jump in end of animation The way I understand the docs, is that you'll rather want to .set the transformPerspective on the element you are going to do 3D transforms on - as in beforehand in contrast to adding the transformPerspective to your tween. To get your elements to have a true 3D visual perspective applied, you must either set the perspective property of the parent element or set the special transformPerspective of the element itself (common values range from around 200 to 1000, the lower the number the stronger the perspective distortion). [...] [...] //or apply perspective to a single element using "transformPerspective" gsap.set(element, {transformPerspective: 500}); https://greensock.com/docs/v3/GSAP/CorePlugins/CSSPlugin#h2-3d-transforms Looks pretty smooth to me then. See the Pen oNpJjdp by akapowl (@akapowl) on CodePen 3 Link to comment Share on other sites More sharing options...
wpsoul Posted April 17, 2022 Author Share Posted April 17, 2022 Ok. this solved. But, I guess, that it's wrong options in documentations, because one of possible ways to add 3d as mentioned in documentation is next https://greensock.com/docs/v3/GSAP/CorePlugins/CSSPlugin#h2-3d-transforms gsap.defaults({transformPerspective: 500}); and this makes wrong animation. We must set to object and not to tween See the Pen rNpoORy by igor-sunz (@igor-sunz) on CodePen Link to comment Share on other sites More sharing options...
akapowl Posted April 17, 2022 Share Posted April 17, 2022 🤔 Right - maybe I was wrong. I think, we'll have to wait for somebody else to jump in. Link to comment Share on other sites More sharing options...
Solution GreenSock Posted April 18, 2022 Solution Share Posted April 18, 2022 Yes, I can see why that line in the documentation could cause confusion and I removed it. When you set something in the gsap.defaults({...}), that is ADDING it to every tween. Literally, EVERY tween. So when you do a gsap.from(...) that would be effectively saying "animate these elements from transformPerspective: 500 to whatever their transformPerspective is now (which is most likely 0)". When you animate transformPerspective to 0, it starts looking odd as it approaches 0, like between 100 and 0 simply because of the nature of how the browser renders it. That has absolutely nothing to do with GSAP. Make your tween longer and open Dev Tools and watch what happens. GSAP is doing exactly what you instructed it to do, and it's doing it smoothly. But visually, things just render strangely at very low transformPerspective values. You could even remove GSAP from the equation and just set those values directly in the CSS and see how it looks. Does that clear things up? 2 Link to comment Share on other sites More sharing options...
wpsoul Posted April 18, 2022 Author Share Posted April 18, 2022 So, proper way to get correct look is gsap.set to object itself or css property to parent? I checked gsap set on site and it looks correct, does it affect performance? Do we need to assign will-change? Link to comment Share on other sites More sharing options...
GreenSock Posted April 19, 2022 Share Posted April 19, 2022 20 hours ago, wpsoul said: So, proper way to get correct look is gsap.set to object itself or css property to parent? Whichever you want. There's no "right" way. It depends on the look you want. 20 hours ago, wpsoul said: does it affect performance? Do we need to assign will-change? I wouldn't expect it to have any significant effect, no. Sometimes it is smart to add will-change: transform but it's not always best. Again, it very much depends on your priorities. If you're experiencing performance problems, I would recommend trying it to see if that helps. Sometimes will-change makes things look a little fuzzy due to the way the browser renders things (totally unrelated to GSAP). 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now