Jump to content
GreenSock

soraya

animate dot particles on bezier path

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

Hi 

 

I am trying to animate some particles along a bezier path in order to get a movement close the way the particles moves on this link 

 

http://banners.bwmdentsu.com.au/aurora/

 

here is the codepen that I have created

See the Pen domJvY by sorayao (@sorayao) on CodePen

 

I have the animation for my particles working pretty much as I want in terms of flying effect, color change and opacity and scale. 

 

Now the issue is that all the particles are created from one single position.

What I am trying to achieve is, each time a particle is created, it is originated from a point along a bezier path ( see white square animation path for example)

 

I have managed to have each of my particle to be created in a div:id="particle"+i  so they all have a single id 

 

I guess what is needed not is to set the position of each div:id="particle"+i as a point on the variable path 

 path = [{x:0, y:0}, {x:50, y:100}, {x:200, y:200}, {x:350, y:0}]

 

 

I have been stuck on this all day... 

I am hoping for Jquery/GSAP guru to help me ! 

 

Many thanks 

See the Pen domJvY  by sorayao (@sorayao) on CodePen

Link to comment
Share on other sites

hmm, it looks like you deleted the pen or made it private (can't see it)

 

In order to place objects along a path that a Bezier tween creates, you can just advance the progress() or time() of the tween and grab the x/y coordinates of the target.

 

This demo shows how to use a loop to quickly iterate through the progress() of the tween in a fixed number of steps and place some dots

 

var path = [{x:0, y:0}, {x:100, y:400}, {x:300, y:20}, {x:400, y:200}, {x:500, y:0}], 
    tween = TweenMax.to(".box", 3, {bezier:path, ease:Linear.easeNone, paused:true})
    target = document.getElementById("target"),
    dots = 80;


//center the box around path points
TweenLite.set(target, {xPercent:-50, yPercent:-50})


//use a for loop to very quickly increment the position of the tween's playhead and place a dot using the target's x and y positions.
for (var i = 0; i <= dots; i++){
  var dot = $("<div class='dot'></div>").appendTo($("body"));
  tween.progress(i/dots);
  TweenLite.set(dot, {x:target._gsTransform.x, y:target._gsTransform.y});
}

 

 

http://codepen.io/GreenSock/pen/yNKjjG/?editors=001

  • 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.
×