fperucic / treant-js

Treant.js - javascript library for drawing tree diagrams
MIT License
864 stars 314 forks source link

Repaint when tree is hidden #177

Open FedericoGarciaGarcia opened 9 months ago

FedericoGarciaGarcia commented 9 months ago

I have two tabs (using Bootstrap). One renders a table, and the other renders a tree with Treant.js. Because the tree tab is initially not active, I need to call chart.tree.reload() when the tab becomes visible:

$(document).on('shown.bs.tab', '#tab-id', () => {
  chart.tree.reload();
});

The problem is that the browser window scrolls all the way to the top when the tree reloads, because for a brief moment the tab container goes from having the height of the table to having no height.

Is there a way to reload the tree offscreen in order to prevent this issue from happening? Maybe passing a width to the tree config since I know the sizes beforehand?