Jump to content
GreenSock

Payman

How to prevent liveSnap from triggering on click?

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

When I click on a draggable object the liveSnap function triggers (and object jumps for no reason as a result).

How can I prevent it from triggering on click?

 

For example in this codepen when I click object it should NOT change it's color, it should change it only when I start dragging.

See the Pen WGAaVk by alecpro (@alecpro) on CodePen

Link to comment
Share on other sites

I found a workaround by checking "this.isDragging" flag. But it feels like a bug for me, you can close this topic if you think otherwise. Thanks!

Link to comment
Share on other sites

I'm not quite sure why that'd be considered a "bug" for liveSnap (where any interaction would implement snapping), but based on that codepen wouldn't it be much more straightforward to just use an onDragStart? That only gets fired when you actually start dragging, so a click won't trigger it. 

Link to comment
Share on other sites

This is just to prove that liveSnap triggers on click, the actual issue is that, for example, if you have a grid or a guideline and click on object to select it - it snaps to the grid or a guideline when it should stay. liveSnap is a part of dragging motion, it should not be triggered on click

Link to comment
Share on other sites

I would have to agree with @Payman. That's also what it says in the docs.
 

allows you to define rules that get applied WHILE the element is being dragged

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