Jump to content
Search Community

Draggable Bounds - Absolute values

admin web 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

31 minutes ago, GreenSock said:

I didn't quite understand your question. I also didn't notice you using any "bounds". I'd like to help, but can you clarify what you're asking? 

 

From looking at the demo, I can only assume he would like to limit the dragging of the letter to the area of the back area...

Link to comment
Share on other sites

 

your demo had a lot of code I didn't understand especially relating to the 2 different Draggables that were being enabled and disabled.

 

The biggest problem seemed to be in the selector you were using for Draggable too

 

var drag = $('body .jacket-image .active svg');

 

Not sure why the selector needs to be that complicated but it appears its trying to select the entire svg. Since the SVG includes the patch and the jacket image I think its better just to select the patch so I gave the patch a clear id of "patch".

 

I got rid of all the code that was not related to keeping the patch draggable within the bounds of the back of the jacket and this seems to work.

 

var R = Draggable.create( "#patch", { type: "x,y", bounds:{minX:-100, maxX:80, minY:-50, maxY:200}});


 

See the Pen jKRNyZ?editors=0011 by GreenSock (@GreenSock) on CodePen

 

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