Jump to content
GreenSock

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

Draggable HitTest Get ID of Hit Area

Recommended Posts

Hi everyone,

 

I know i can go about this a different way and make it work but i was still wondering what the answer would be to this questions i have.

 

I'm trying to get the id of the element in the hit test that the target is going over.

 

Ex:

 

 if (this.hitTest("#circle1", "50%")) {        }
 
How would i access and get the value of #circle1 inside the hittest if statement?
 
this.target is the object being dragged, but i want to know what i could use to get the "circle1" value?
 
I'm trying to get html info from that circle1.
 
Thanks!
Brad
Link to comment
Share on other sites

Hi TopGUN121  :)

 

pls try like this :

 

var Targets = document.querySelectorAll('.Targets');

Draggable.create('.Draggable',{
  onDragEnd:function(){
    for(var i=Targets.length; i--{
      if(this.hitTest(Targets[i],'50%')){
         console.log(Targets[i].id)
      }
    }
  }
});
  • Like 4
Link to comment
Share on other sites

This worked perfectly for my needs!  thank you!

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