Share Posted June 10, 2019 Hi, Is there a reason why we can't use a function instead of a number with the duration parameters in StaggerTo() ? Here is a change I made in TweeMax.js to make what I wanted. And here is a quick example : https://animation-lover.glitch.me/ (click button 'Performances') 1 Link to comment Share on other sites More sharing options...
Share Posted June 10, 2019 This just a wild guess but I think it's because you're not directly passing a function you're passing a conditional statement. Maybe try wrapping it in a function and returning the value. Something like this: function () { return (ternary operator); } Link to comment Share on other sites More sharing options...
Share Posted June 10, 2019 You actually can do it by using the "cycle" special feature in the stagger methods. Kinda like: TweenMax.staggerTo(".box", 1, { x:1000, cycle:{ duration:function(i, target) { //<-- this is the key. return i * 1 + 0.5; } } }); Does that help? 3 Link to comment Share on other sites More sharing options...
Author Share Posted June 11, 2019 Thanks you Jack - and Visual-Q. I am using this standard solution now :-) But I don't understand why there is this extra-object 'Cycle' because 1/ we can customized 'x', 'y' by object in "vars parameters", without using cycle. 2/ this can lead to conflit between parameters (in your exemple, "1 sec" versus "i * 1 + 0.5") 3/ and why the name is 'Cycle' ? There are no repeating processes with it. Anyway ! Thanks you again :) Link to comment Share on other sites More sharing options...
Share Posted June 11, 2019 Hi @JackIsJack44, Here are some info Happy cycling ... Mikel 2 Link to comment Share on other sites More sharing options...
Share Posted June 11, 2019 10 hours ago, JackIsJack44 said: But I don't understand why there is this extra-object 'Cycle' because 1/ we can customized 'x', 'y' by object in "vars parameters", without using cycle. 2/ this can lead to conflit between parameters (in your exemple, "1 sec" versus "i * 1 + 0.5") 3/ and why the name is 'Cycle' ? There are no repeating processes with it. Yes, GSAP searches the "vars" object for function-based values. However, the duration isn't in the vars object - it's a standalone parameter. "cycle" was originally intended to cycle through a set of values (as the page @mikel referred to explains) but then we added features to it to accommodate function-based values too. That pre-dated function-based values in the regular "vars" object. I'm working on GSAP 3.0 and I'll definitely make duration accommodate function-based values. Don't worry. I'm pretty excited about 3.0. It'll be several months before it's ready, though. For now, I'd recommend just using cycle. 3 Link to comment Share on other sites More sharing options...
Share Posted June 11, 2019 39 minutes ago, GreenSock said: I'm pretty excited about 3.0. This is me thinking about 3.0. 1 Link to comment Share on other sites More sharing options...
Author Share Posted June 11, 2019 Thank you for these extra-informations ! Have fun 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