clientIO / joint

A proven SVG-based JavaScript diagramming library powering exceptional UIs
https://jointjs.com
Mozilla Public License 2.0
4.72k stars 853 forks source link

[Bug]: paper 'render:done' event no longer fires after unfreeze #2740

Closed ArthurWietzorek closed 3 months ago

ArthurWietzorek commented 3 months ago

Current versus expected behaviour

We are currently updating our application from JointJS 3.6.5 to 4.0.4. In our application we use the paper.freeze() function to keep the state of the Paper while displaying other UI elements and then paper.unfreeze() once the PaperScroller has been appended to an HTML element in the DOM tree again.

Before unfreezing we listen to paper.once('render:done', ...) to apply the same PaperScroller zoom and center as before the user left. This worked perfectly fine before updating, but now the 'render:done' event is sometimes not emitted.

While the Paper is frozen we use a different UI to update various properties of the Elements and Links, not all of them leading to actual changes in the SVG to be displayed. It seems to be the case that the 'render:done' event is now only emitted when the changes made while the Paper was frozen would actually cause a difference in the resulting SVG.

Was this an intended change made to that event? Is there a workaround for us? Applying a zoom and center to the PaperScroller before the Paper is done rendering does not work, there is no other event to listen to and setting a timeout to apply those changes is not a stable solution.

Steps to reproduce

(I am still working on reproducing this problem in the Kitchensink and will update this issue later)

  1. Freeze the paper.
  2. Make changes to the graph that do not affect the displayed SVG.
  3. Listen to the 'render:done' Event.
  4. Unfreeze the paper.
  5. In version 3.6.5 the event is emitted, in version 4.0.4 it is not

Version

4.0.4

What browsers are you seeing the problem on?

Firefox, Chrome

What operating system are you seeing the problem on?

Windows, Linux

kumilingus commented 3 months ago

I am not aware of such a change.

The render:done should not be triggered if there is nothing to update (such as updating a custom top-level attribute).

I will need steps to reproduce as this does not fire render:done event.

paper.on('render:done', (o) => console.log('render:done', o));
paper.freeze();
paper.model.getElements()[0].set('myattribute', 1);
paper.unfreeze();
// No `render:done` is triggered in v3.6

Applying a zoom and center to the PaperScroller before the Paper is done rendering does not work?

Why does not this work? What exactly do you do? Updates to the paper do not change the zoom or the center of the visible area in the paper scroller.

ArthurWietzorek commented 3 months ago

You are right, after further search i found that our application did re-initialize the entire graph and therefore cause changes that would require another render, which it no longer does now.

Updates to the paper do not change the zoom or the center of the visible area in the paper scroller.

I do not know why this does not work in our case, but i will research that and open a different issue if i can find something wrong.

I will close this issue as it was simply a mistake on our part and not a bug in JointJS after all. Thank you very much!