Skip to content

Fix: Remove render callback after first usage in simulation end#31

Merged
tonilastre merged 1 commit intorelease/0.1.4from
fix-render-callback-on-multiple-simulations
Oct 20, 2022
Merged

Fix: Remove render callback after first usage in simulation end#31
tonilastre merged 1 commit intorelease/0.1.4from
fix-render-callback-on-multiple-simulations

Conversation

@tonilastre
Copy link
Contributor

@tonilastre tonilastre commented Oct 20, 2022

It fixes the following issue:

If you use Orb like this:

  • Render the graph after which you want to console.log a message and recenter the graph
  • After 5 seconds, change the view settings by enabling physics
orb.view.render(() => {
  console.log('Rendering done');
  orb.view.recenter();
});

setTimeout(() => {
  orb.view.setSettings({
    render: {
      isPhysicsEnabled: true,
    },
  });
}, 5000)

The problem:

  • When enabling the physics, simulation of the nodes will start
  • When the simulation ends, it will call the same callback from the first render (console.log and recenter)

The solution:

  • After calling the user's callback, remove it so it is not called anymore in simulation end event

@tonilastre tonilastre requested a review from cizl as a code owner October 20, 2022 10:36
@tonilastre tonilastre merged commit 427a56f into release/0.1.4 Oct 20, 2022
@tonilastre tonilastre deleted the fix-render-callback-on-multiple-simulations branch October 20, 2022 10:40
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

Successfully merging this pull request may close these issues.

1 participant