(This page includes affiliate links. If you click and purchase, I receive a small commission at no extra cost from you and that way you can support me. I only recommend tools that I have personally used and loved.)
Get Elementor Pro Today –
1 – Elementor Pro
Create any Element Draggable with GSAP
With this GSAP code, you can simply make anything draggable and also define a bounding box so that the element cannot be dragged outside it.
- In below code, we add transition:none as Elementor adds transition:all to all elements by default and that messes up with GSAP code.
- In Draggable.create(‘.ADD-CLASS-NAME-HERE‘), we add the class name of the element that should be draggable.
- in bounds: ‘.ADD-BOUNDING-CLASS-NAME‘, we add the class of the container that will act as a bounding box for the draggable container. This way the draggable element cannot be dragged outside the bounding container.
- We also add script src to reference and run GSAP library and its draggable library to our website.
- inertia:true makes it glide. If you don’t want it to glide make it false or remove that line.
- Change type to your desired effect. type:rotation would make it spin. Check gsap documentation for more types.
2 – GSAP Dragging with Inertia & Snap (Smoothing and Reset)
With this GSAP code, you can simply make anything draggable and also define a bounding box so that the element cannot be dragged outside it.


- dm-drag-element-2 is the CSS of the draggable element.
- dm-drag-container-2 is the CSS of the bounding box container. (optional) – Remove from code too if not needed.
- Snap makes it reset to original location. Remove if not needed. (line 21 – 24)
- edgeResistance can add resistance when leaving bounding box. You can also add dragResistance. Check video for detail.
- dm-drag-element-3 is the CSS of the draggable element.
- Snap makes it reset rotation.
Important: Only use //1 or //2 code based on your requirements.