Skip to content

outOfBounds variable not available in callbacks #764

@davechisholm

Description

@davechisholm

Currently, if the outofbounds variable is true, this stops angular-ui-tree from updating the source array BUT, the beforeDrop callback is called prior to this, and doesn't have access to the outofbounds variable. I use the beforeDrop function to update the API with the move data, so it was doing the api call even if the move was 'out of bounds'. I solved this by passing the outOfBounds var to the callback data like so:

var dragEventArgs = dragInfo.eventArgs(elements, pos, outOfBounds);

and then updating the eventArgs function:

eventArgs: function (elements, pos, outOfBounds) {
                return {
                  source: this.sourceInfo,
                  dest: {
                    index: this.index,
                    nodesScope: this.parent,
                    outOfBounds: outOfBounds
                  },
                  elements: elements,
                  pos: pos
                };
              },

I'm then able to make sure event.dest.outOfBounds is false before updating the api

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions