Jump to content
GreenSock

Draggable.timeSinceDrag()

Draggable.timeSinceDrag( ) : Number

Returns the time (in seconds) that has elapsed since the last drag ended - this can be useful in situations where you want to skip certain actions if a drag just occurred.

Returns : Number

the time (in seconds) since the last drag ended

Details

Returns the time (in seconds) that has elapsed since the last drag ended - this can be useful in situations where you want to skip certain actions if a drag just occurred. For example, imagine a draggable DIV with a bunch of child elements that have onclick handlers - if the user clicks on of those and drags the whole DIV and then releases, you might want to ignore that "click" because the user was intending to drag, not click (don't forget to setdragClickables:true in the Draggable):

$("#myDiv a").click(function(e) {
if (Draggable.timeSinceDrag() > 0.2) {
//do stuff, but not if the user just dragged within the last 0.2 seconds
}
});

There is also timeSinceDrag() instance method.

myDraggable.timeSinceDrag();
Copyright 2017, GreenSock. All rights reserved. This work is subject to theterms of useor for Club GreenSock members, the software agreement that was issued with the membership.
×