ZomoXYZ
ZomoXYZ

Reputation: 1861

Events triggered on jquery dragging

Is there a way to have an event triggered when you drag an item to a certain place, or drag it a certain amount?

For example, with a slider you can have an event happen when you drag the slider like this:

$( '.slider' ).slider( {
  slide  : function(){},
  change  : function(){}
});

is there anything like this with a draggable element using jquery ui?

Upvotes: 0

Views: 39

Answers (3)

ZomoXYZ
ZomoXYZ

Reputation: 1861

Found out it is very simple:

$('#id').draggable({
    drag: function(){
        //code here
    }
});

Upvotes: 0

David K.
David K.

Reputation: 339

I saw you tagged with JQUI so if you are using JQuerUI's slider, it has functions for start and change. If you keep the start number around and compare on each call to change you can get offset of a given pull.

Upvotes: 0

Jackson
Jackson

Reputation: 3518

Check this page out

/* events fired on the draggable target */
 element.addEventListener("drag", function( event ) {
    //drag code here
 }, false);

Upvotes: 1

Related Questions