Search code examples
javascriptjqueryjquery-eventsdrag

jQuery drag event doesn't seem to have deltaX property


I am trying to create my own slider plugin with jQuery and this library for the drag event. However, on callback for the event, the deltaX-property doesn't seem to occur, which is really weird since it exists in the documentation. I am using version 2.2 of the library. I am using the library like this:

$('#myelement').bind('drag',function(e){
    console.log(e);
});

Does anyone have any experience with the drag event and can help me? I have also tried using the 'drag' method of the library with the very same result. The deltaX property doesn't exists in the callback.


Solution

  • is "drag" in bind function callback @params

    bind(type, callback); 
    
    callback(event, delta, deltaX, deltaY);
    

    so;

    $('#myelement').bind('drag',function(e, delta, deltaX, deltaY){
        console.log(e, delta, deltaX, deltaY);
    });