Jump to content
Search Community

Draggable items with bounds

BernasN135 test
Moderator Tag

Recommended Posts

Hi, I've been creating my portfolio on Webflow. On my "About me" page I want to have a "tool stack" and "expertises" section where I put related words, but I would like all these words to be draggable but to have limits (so they can't be dragged across the entire page), like In the image below I already have visually defined limits, but as I'm new to the code I don't know how to create these limits. Below is also the code I used to drag the "tags". Thanks already!

<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
    <script>
      $(function() {
        $(".tool_stack_items").draggable({
        });
      });
    </script>

 

Captura de ecrã 2024-06-11 105759.png

Link to comment
Share on other sites

Hi @BernasN135 and welcome to the GSAP  Forums!

 

In Draggable you can define bounds using a selector, a DOM element or specific values. From the Draggable docs:

https://gsap.com/docs/v3/Plugins/Draggable/#bounds

 

Here is a simple demo of how you can set it up:

See the Pen QWRqQeJ by GreenSock (@GreenSock) on CodePen

 

Hopefully this helps.

Happy Tweening!

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