Jump to content
Search Community

Create Tween animation from X and Y coord

cpkn_dev test
Moderator Tag

Recommended Posts

Hi all,

 

Currently I have a draggable ball that generates a "wave" like circle. I am just starting out with Greensock, I was able to figure out how to emit the wave from the point that I'm dragging, but ideally the wave would be relative to the parent container and stay where they are created. I have a function called CreateNewRing() in my js file which I have set to an interval I'd like to create these rings.

 

If anyone has any tips or examples that might help me figure this out I'd be very appreciative!

 

Thanks

See the Pen yLOXBKe by lsencabaugh (@lsencabaugh) on CodePen

  • Like 1
Link to comment
Share on other sites

Hi @cpkn_dev

 

There's a few things you'll want to consider for this:


1: If the rings are children of the draggable target, they will move with it, so you'll want to make the rings direct children of the container.

 

2: As you're setting the rings, you'll want to keep track of which are active, or you'll be moving the whole animation to the new location, which I assume is not what you're trying to do (I'm assuming you want each new ping to happen at the new location, kinda a ripple effect), so for that you'll want to check which <span> isn't currently active (probably just by cycling through their index) and set that one/ones at the new location, or append the spans via JS, animating them from the dragged location (which you can get from draggable with less cost than checking bounding box every time), and remove the appended span when the animation finishes.

Hope this helps point you in the right direction.

  • Like 2
Link to comment
Share on other sites

Hi guys, I'm back again. I'm working on the same animation so I figure'd I'd still use this thread. I'm trying to now make it so the ball will constantly "drag" as I hold in during a mousedown event on the dragable ball. Ideally the ball would keep moving towards the point the mouse is "mousedown" on until the user decides to let go.

 

It works well with the high drag Resistance. I've been trying to use the onDrag event but it doesn't know if I'm still holding on to it or not.

 

Any advice welcomed

 

See the Pen VwazjZx by lsencabaugh (@lsencabaugh) on CodePen

 

 

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