Jump to content
Search Community

How can I make card elements draggable?

Nemanja Pavlovic test
Moderator Tag

Recommended Posts

Hello @Nemanja Pavlovic

 

With GSAP's Draggbale it's as simple as creating a Draggable for each of your cards and using the header of each card as the trigger for the Draggable.

 

See the Pen PoexGLj by akapowl (@akapowl) on CodePen

 

 

 

From the docs:

 

trigger [Element | String | Object] - If you want only a certain area to trigger the dragging (like the top bar of a window) instead of the entire element, you can define a child element as the trigger, like trigger: yourElement, trigger: "#topBar", or trigger: $("#yourID"). You may define the trigger as an element or a selector string, or a jQuery object.

 

https://greensock.com/docs/v3/Plugins/Draggable

 

If you want your Draggables to also be throwable (like it looks to be the case on that website you linked) you will need to include the InertiaPlugin, which is a Bonus Plugin for Club-Greensock members of the ShockinglyGreen tier and above.

 

https://greensock.com/docs/v3/Plugins/InertiaPlugin
 

  • Like 2
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...