clientIO / clientIO/joint

z-Index initialization issue in async mode

Open
#1,320 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug won't fix
Dominant language
JavaScript
Stars
5.4k
Forks
893
Avg merge
3d 3h
Merged PRs (30d)
26

Description

If I want to have a link displayed below my cells on initialization, it should be as simple as adding z: 0 to the link and z: 1 to the cells while calling the constructor. This works as expected in the normal synchronous rendering mode, but fails if async: true is set in the paper options.

Here is a modified code from the Hello-world-example to reproduce the problem:

var graph = new joint.dia.Graph;

var paper = new joint.dia.Paper({
    //async: true,
    el: document.getElementById('myholder'),
    model: graph,
    width: 600,
    height: 100,
    gridSize: 1
});

var rect = new joint.shapes.standard.Rectangle({
    z:1
});
rect.position(100, 30);
rect.resize(100, 40);
rect.attr({
    body: {
        fill: 'blue'
    },
    label: {
        text: 'Hello',
        fill: 'white'
    }
});
rect.addTo(graph);

var rect2 = rect.clone();
rect2.translate(300, 0);
rect2.attr('label/text', 'World!');
rect2.addTo(graph);

var link = new joint.shapes.standard.Link({
    vertices: [{x: 600, y: 50}],
    z:0
});
link.source(rect);
link.target(rect2);
link.addTo(graph);

In synchronous mode, the graph is rendered correctly as
grafik
whereas in asynchronous mode the results looks as follows
grafik
because the order in the svg tree is not adapted correctly.

Btw, for some reason if I move the source or target (by the corresponding link tools), somehow it seems to re-render and the link is correctly displayed below the rectangle.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the modified Hello-world example using joint.dia.Paper and the async paper option. Start by tracing asynchronous initialization and how the SVG tree is ordered by z values; done means the link with z: 0 is rendered below the cells with z: 1 immediately, without moving a source or target first.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.