Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by Dal1980

  1. Thank OSUblake That's very dry code! I like that a lot. Works perfectly thank you very much. I've avoided using shorthand if statements all these years but I think you just convinced me to start using them. I think they were always something I hated because you used to see them a lot in PHP for nasty template logic but those days are gone now I suppose This has helped me considerably in understanding some things about greenstock's GSAP.
  2. Thanks OSUblake The code runs successfully but the randomiser function is only requested once per run. With the first example, this gathers randomised results for each pass (not entirely sure why it passes through here more times than it has matching elements). So to randomise the stagger for elements I need to have a random number generated for each one. This should highlight the problem. Just call the either example1() or example2() from the top
  3. Hi, I'm new to the forums, new to GreenSock GSAP too. So far I'm using it quite effectively with the 5% of what I've worked with I've got a bit of an issue trying to get a small script working. I wonder if anyone can help. The following code effects the x property with a randomisation of 2 possible values (-100% or 100%) which all works great: var wipeAnimation = new TimelineMax() .staggerFromTo('section.panelx', 1, { x:function(){ var randWay = parseInt((Math.random() * 2) + 1); if(randWay == 1) return "-100%"; else if(randWay == 2) return "100%"; } }, {x: "0%", y: "0%", ease: Linear.easeNone}, 1) The issue I have is that I also would like to randomise the property itself between 'x' and 'y' with the randomised value of before (-100% or 100%) var wipeAnimation = new TimelineMax() .staggerFromTo('section.panelx', 1, { function(){ var randWay = parseInt((Math.random() * 4) + 1); if(randWay == 1) return {x:"-100%"}; else if(randWay == 2) return {x:"100%"}; else if(randWay == 3) return {y:"-100%"}; else if(randWay == 4) return {y:"100%"}; } }, {x: "0%", y: "0%", ease: Linear.easeNone}, 1) I'm trying to return both the property and value as one as an object but does't seem to understand. Is there a way to do this? Many thanks Dal1980