jQuery UI : Before start draggable

前端 未结 4 1272

How to implement a before start event to have a change to change the position and place in the DOM of the draggable element before jQueryUI start to drag?

4条回答
  •  北荒
    北荒 (楼主)
    2020-12-17 05:56

    You could extent prototype method:

    SEE DEMO

    var oldMouseStart = $.ui.draggable.prototype._mouseStart;
    $.ui.draggable.prototype._mouseStart = function (event, overrideHandle, noActivation) {
        this._trigger("beforeStart", event, this._uiHash());
        oldMouseStart.apply(this, [event, overrideHandle, noActivation]);
    };
    
    $("#draggable").draggable({
        beforeStart: function () {
            console.log('beforeStart::');
        }
    });
    

提交回复
热议问题