Jump to content
GreenSock

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

Draggable | Get position of an element?

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 guys!

 

I'm not yet very experienced in HTML/JS, I come from AS3, don't blame me !

 

I'd like to get the X position of an element when user is moving it in order to know when this element is touching another and fire some events (like a collision or something).

 

 

I've tried this but it doesn't work :

 

Draggable.create( $mainProduct , {
        type:"x,y",
        edgeResistance:0.4,
        bounds:"#dragAndDrop",
        throwProps:true,
        onDrag:function() {
            
            $("h2").text( parseInt ($mainProduct.css('left')));
           
            
        }
 
It always return the initial position (50 in my case) wherever is the element.
 
Thanks a lot
:-P
Link to comment
Share on other sites

Pfff..

Sorry for bothering!

 

Simple as this :

parseInt (this.y);

 

Please ignore this post!!!

 

 

BTW, thank you for your amazing products

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