Jump to content
Search Community

Using Bounds only when dragging...

mimeartist 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

Is there a way of only using the bounds when an item is being dragged... I'm trying to animate items off screen, and when I start to animate them, if they're already offscreen they arrive into the div they're bound to... but I only need them to stick to the bounds when dragging.

 

Hope that makes sense!

Link to comment
Share on other sites

I'm not quite sure I understand. Do you have a simple codepen demo or something? 

 

You can disable() the Draggable instance if you want, or you can set the bounds to new values like draggableInstance.vars.bounds = {...} (or null) and then call update() on the Draggable. Not sure if that answers your question at all, but it'd be super helpful to see a quick demo that shows the problem. 

  • Like 3
Link to comment
Share on other sites

Trouble is the site is too complicated to make a simple Codepen... sorry...

 

So I'm assigning this now when the user starts to drag

 

Draggable.get('#slide' + theBounder).applyBounds("#siteContainerInside");

 

is there a way to turn off bounds after onDragEnd?   guess I could set a bounds that is much bigger than the webpage, but just wondering if there is a way to remove it?

Link to comment
Share on other sites

So...

 

Draggable.get('#slide' + theBounder).applyBounds({minX:-1000, maxX:10000, minY:-1000, maxY:10000});

 

Seems to work... I'm assuming this won't have any performance impact...

 

I know what you're saying about just turning off the 'draggability', but this easier than keep track of which ones to turn on and off... as the animating them offscreen was getting screwed up by the bounds somehow.

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