Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
phoenixrip

this.hitTest in onDragEnd but for final position

Recommended Posts

Is there a smart way of performing a hitTest when then drag part of a throw finishes (onDragEnd), but hit testing what will be the final position of the element once the throwprops tween has finished? I know I can access the end x and end y in onDragEnd but don't know how I would go about using the this.hittest with that :)

 

Thanks in advance

Link to comment
Share on other sites

That is super smart! :) Thanks!

 

For anyone coming here looking for the same solution, it should maybe be noted that the code Blake very helpfully posted will cause any onThrowEnd function you have to be called at the same time as onDragEnd as it sets the throw tween progress to 1 (ie finished so fire the onThrowEnd) and then back again.

 

I got round this by using 0.99 progress to do the hitTest, almost exactly the same as the final position, but without accidentally triggering my onThrowEnd before the throw has really begun :)

onDragEnd: function(){
	var hit = false
	if (this.tween) {
	this.tween.progress(0.99)
	hit = this.hitTest(centerpoint, '5%')
	this.tween.progress(0)
}
},
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.
×