KineticJS icon indicating copy to clipboard operation
KineticJS copied to clipboard

dragDistance does not stop calls to DragBoundFunc

Open MarkusLeth opened this issue 11 years ago • 2 comments

Hi,

I had to add !dd.isDragging to stop calls to DragBoundFunc, Do you agree that that this is the correct behavior?

Cheers, ML

Kinetic.Node.prototype._setDragPosition = function(evt) {
    var dd = Kinetic.DD,
        pos = this.getStage().getPointerPosition(),
        dbf = this.getDragBoundFunc();
    if (!pos || !dd.isDragging) {
        return;
    }
    var newNodePos = {
        x: pos.x - dd.offset.x,
        y: pos.y - dd.offset.y
    };

    if(dbf !== undefined) {
        newNodePos = dbf.call(this, newNodePos, evt);
    }

    this.setAbsolutePosition(newNodePos);
};

MarkusLeth avatar Jun 09 '14 13:06 MarkusLeth

I think dragDistance should be relative to dragBoundFunc. Do you have an example where your behaviour is important?

lavrton avatar Jun 10 '14 01:06 lavrton

I have the same problem. I my case, I am developing a browser game with KineticJS in which it is important that dragBoundFunc is only called when an object was actually moved.

Although I could also take a detour via "drag move" and realize my own dragBoundFunc-alternative, but this would mean a lot of effort for me. It would be great if this bug will be fixed in the next version of KineticJS.

@lavrton If there are also uses for relative behavior, then there should be an option for this. Currently behaves dragDistance not relative to dragBoundFunc.

nodecode avatar Jun 19 '14 10:06 nodecode