Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some events outside angular's digest cycle #54

Open
Devqon opened this issue Jun 22, 2016 · 1 comment
Open

Some events outside angular's digest cycle #54

Devqon opened this issue Jun 22, 2016 · 1 comment

Comments

@Devqon
Copy link

Devqon commented Jun 22, 2016

Hi,

At least the 'deselectNode' occurs outside angular's digest cycle (maybe more).

I have this (stripped) setup:

this.events = {
    selectNode: this.nodeSelected,
    deselectNode: this.nodeSelected
};

<div vis-network events="$ctrl.events"></div>

The 'nodeSelected' roughly looks like this:

public nodeSelected = (items) => {
    if (items.nodes.length) {
        this.selected = items.nodes[0];
    } else {
        this.selected = null;
    };
};

If i display the selected like this:

<pre ng-bind="$ctrl.selected | json"></pre>

It updates the selected if the 'selectNode' is triggered, but not when the 'deselectNode' is triggered, only after a new digest cycle. The current workaround I implemented is this:

public nodeSelected = (items) => {
    if (items.nodes.length) {
        this.selected = items.nodes[0];
    } else {
        this._$scope.$apply(() => {
            this.selected = null;
        });
    };
};

What causes this issue?

@Tooa
Copy link

Tooa commented Aug 24, 2016

I found a similar problem with the stabilizationDone callback. The following does not always trigger the $watchCollection for the options field. However, sometimes it is triggered quite late. I try to provide a JSBin.

``
$scope.graphEvents = {
"stabilized": stabilizationDone
}

function stabilizationDone() {
$scope.graphOptions['physics'] = false;
}
``

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants