Jump to content
Search Community

Draggable with anchors?

cormack test
Moderator Tag

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 having a little problem dragging an anchor, look at the CodePen please.

 

An additional problem is that the SVG can be dragged clicking not only in the SVG but (specially at the left) when i am clicking far away from the SVG (100 pixesla i guess).

 

All is in the Codepen. Again, excuse if maybe some of this questions are very basic.

 

Please advice, any help are welcome :)

 

 

See the Pen NqVvQX by Cormack (@Cormack) on CodePen

Link to comment
Share on other sites

I like to put outlines around elements while positioning them, which will let you clearly see the problem.

 

To drag an anchor, first you need to set 'dragClickables: true' on your draggable. But an anchor is an inline element, so you need to wrap it in something like a div or set it to display block in you CSS.

 

See the Pen eNaGga by osublake (@osublake) on CodePen

  • Like 3
Link to comment
Share on other sites

Great!!  Thanks OSUblake and Diaco

 

@Diaco, what i don't understand (because i don't know much or anything about SVG) is how do you calculate correctly the height and the witdth and the correct calculation of the childs.

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