Jump to content
GreenSock

mimeartist

Click a panel within a draggable

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

The aim is to have X amount of images in a long strip, that can be flicked along horizontally... but also allow for an image to be clicked... I believe I'm halfway there in that I need to put an on click on the holder of these images to stop propagation, but have got myself tied up in knots...

 

See the Pen AiCtu by mimeArtist (@mimeArtist) on CodePen

 

Basically I want the images to only register a click when they've been clicked on, and not when the strip is dragged (it seems the image will trigger a click if the mouse is then released whilst over one of the images in the strip

Link to comment
Share on other sites

Sure, that's exactly what the new timeSinceDrag() method is for. Check out this CodePen fork:

http://codepen.io/GreenSock/pen/fcba06ccd7dd6ffb71f143b1b2fc187b

 

Basically, in your click handler, you use this conditional logic:

$(".box").click(function() {
    if (Draggable.timeSinceDrag() > 0.2) {
        // do stuff
    }
});

Does that clear things up for you? 

  • Like 2
Link to comment
Share on other sites

Perfect! How long has timeSinceDrag been around?!

 

Thanks again!

Link to comment
Share on other sites

Perfect! How long has timeSinceDrag been around?!

 

Thanks again!

Since today's update :D

 

You should subscribe to the newsletter to find out about this

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