Jump to content
Search Community

Issues when I remove DOM element in GSAP Draggable

Suv4o test
Moderator Tag

Go to solution Solved by ZachSaucier,

Recommended Posts

Hello there,

 

First of all I wold like to thank you very much for these useful GSAP libraries. They are truly amazing.

 

I been using GSAP Draggable in the last couple of weeks and I came into an issue that I cannot resolve. I provided a codepen so you can see what exactly I wanna achieve. I also provided a short video with the issue I'm facing.

 

Basically when I add a few new elements in the DOM and then I try to remove them individually, the elements don't stay in the same spot. They move on the Y axis. I don't know what is causing this issue. 

 

What I want to achieve is adding and removing elements in the DOM so they will stay on exact same spot.

 

I hope someone can help me with this issue.

 

See the Pen QWEzzjg by aleks-b-trpkovski (@aleks-b-trpkovski) on CodePen

Link to comment
Share on other sites

  • Solution

Hey Suv4o and welcome to the GreenSock forums. Thanks for supporting GreenSock with a Club GreenSock membership! 

 

This issue is because all of your elements are positioned relative to each other. So when you remove an element earlier on in the DOM, the ones after it move up by the height of the removed element. Does that make sense?

 

To fix it, position your elements absolutely. Or compensate for the removed height by adding to the y position of the elements after the removed one. 

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