Description
Reordering a cell with toFront() / toBack() (or any z change) re-sorts the cell views by re-inserting the cell's SVG node. If a CSS transition on that cell is triggered in the same tick — e.g. toggling a state class that animates fill/stroke — the transition does not play: the property snaps to its final value instead of easing.
That makes two natural things hard to do at once: animate a state change and raise the affected cell above its neighbours.
Version: @joint/core 4.2.x
Minimal reproduction
Two overlapping elements (so a z change actually reorders the DOM), with a CSS transition on the body keyed off a class:
.joint-cell [joint-selector="body"] { transition: fill .3s ease; }
.joint-cell.highlight [joint-selector="body"] { fill: tomato; }
paper.on('element:pointerclick', (view) => {
view.el.classList.add('highlight'); // should animate fill → tomato …
view.model.toFront(); // … but re-sorting re-inserts the node, so it snaps
});
Expected: the body fill eases to tomato over .3s.
Actual: it jumps instantly. (Remove the toFront() line and it animates as expected.)
Workaround
Defer the z / toFront() change until after the transition has finished (e.g. a timeout matching the transition duration), so the re-insert happens when nothing is animating — then both the ease and the reorder occur.
Question
Is this avoidable within JointJS (e.g. reordering without re-inserting the node, or skipping a no-op re-sort), or is it inherent to SVG reordering? Either way a note in the docs would help.
Description
Reordering a cell with
toFront()/toBack()(or anyzchange) re-sorts the cell views by re-inserting the cell's SVG node. If a CSS transition on that cell is triggered in the same tick — e.g. toggling a state class that animatesfill/stroke— the transition does not play: the property snaps to its final value instead of easing.That makes two natural things hard to do at once: animate a state change and raise the affected cell above its neighbours.
Version:
@joint/core4.2.xMinimal reproduction
Two overlapping elements (so a
zchange actually reorders the DOM), with a CSS transition on the body keyed off a class:Expected: the body fill eases to
tomatoover .3s.Actual: it jumps instantly. (Remove the
toFront()line and it animates as expected.)Workaround
Defer the
z/toFront()change until after the transition has finished (e.g. a timeout matching the transition duration), so the re-insert happens when nothing is animating — then both the ease and the reorder occur.Question
Is this avoidable within JointJS (e.g. reordering without re-inserting the node, or skipping a no-op re-sort), or is it inherent to SVG reordering? Either way a note in the docs would help.