Jump to content
Search Community

Looping draggable that snaps without throwProps

lewisSME test
Moderator Tag

Go to solution Solved by GreenSock,

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

I'm trying to make a looping Draggable that snaps and only moves one step at a time.

 

The problem is that with throwProps switched on, the user can throw it more than one 'step' at a time, and with throwProps switched off it doesn't snap at all.

 

I used this pen as a starting point:

See the Pen ee107aeb54bdf4dca1084715d86b5e9c by osublake (@osublake) on CodePen

 

Here's where I've gotten to:

 

Any help greatly appreciated.

See the Pen mWQoye by lewisSME (@lewisSME) on CodePen

Link to comment
Share on other sites

  • Solution

Sorry for the late response - is this what you're looking for?:

http://codepen.io/GreenSock/pen/5ab2ffbfe42ba91d4e90a5fe16e8cf93/

 

It limits things to one position left/right. I also reworked some of the logic so that it handles resizes of the window appropriately (well, you could certainly enhance it further, but the basics are there). 

 

Does that help?

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