Skip to content

Commit de44e67

Browse files
committed
add autoExpand feature to inspector
1 parent c620b25 commit de44e67

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/tools/Inspector.js

+12
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ Inspector.create = function(engine, render, options) {
4747
selectBounds: Bounds.create(),
4848
mousePrevPosition: { x: 0, y: 0 },
4949
offset: { x: 0, y: 0 },
50+
autoExpand: true,
5051
autoHide: true,
5152
autoRewind: true,
53+
hasExpanded: false,
5254
bodyClass: '',
5355
exportIndent: 0,
5456
clipboard: [],
@@ -353,6 +355,16 @@ var _initTree = function(inspector) {
353355
controls.worldTree = $('<div class="ins-world-tree">').jstree(worldTreeOptions);
354356
controls.container.append(controls.worldTree);
355357

358+
inspector.hasExpanded = false;
359+
360+
controls.worldTree.on('refresh.jstree', function() {
361+
// expand tree on first update
362+
if (inspector.autoExpand && !inspector.hasExpanded) {
363+
inspector.hasExpanded = true;
364+
controls.worldTree.jstree('open_all');
365+
}
366+
});
367+
356368
controls.worldTree.on('changed.jstree', function(event, data) {
357369
var selected = [],
358370
worldTree = controls.worldTree.data('jstree');

0 commit comments

Comments
 (0)