Skip to content

Commit

Permalink
scroll to selection
Browse files Browse the repository at this point in the history
  • Loading branch information
kleber-swf committed Sep 16, 2021
1 parent 69b5c1c commit 8efa7cc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
4 changes: 2 additions & 2 deletions TODO.todo
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ BASIC:
[x] automatic expand when selecting
[x] expand / collapse all with alt key
[x] vertical scroll
[ ] horizontal scroll
[ ] scroll to selection
[x] horizontal scroll
[x] scroll to selection

General Features:
[x] editor layout
Expand Down
10 changes: 10 additions & 0 deletions example/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,21 @@ function create() {
child.anchor.set(0.5, 0.5);
child.pivot.set(SIZE, SIZE);

for (let i = 0; i < 10; i++) {
const c = el(0, 0, SIZE, SIZE, child, 'child-a.5-p1');
child = c;
}


// 1 0
child = el(DIST * 0, DIST * 2, SIZE, SIZE, parent, 'child-a1-p0');
child.anchor.set(1, 1);

for (let i = 0; i < 10; i++) {
const c = el(0, 0, SIZE, SIZE, child, 'child-a.5-p1');
child = c;
}

// 1 .5
child = el(DIST * 1, DIST * 2, SIZE, SIZE, parent, 'child-a1-p.5');
child.anchor.set(1, 1);
Expand Down
6 changes: 5 additions & 1 deletion src/editor-view/object-tree/tree-node/tree-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ export class TreeNode extends HTMLElement {

private onClick() { if (this.onNodeSelect) this.onNodeSelect(this); }

public select() { this.classList.add(SELECTED_CLASS); }
public select() {
this.classList.add(SELECTED_CLASS);
this.collapseIcon.scrollIntoView();
}

public clearSelection() { this.classList.remove(SELECTED_CLASS); }

public onCollapseIconClick(e: MouseEvent) {
Expand Down

0 comments on commit 8efa7cc

Please sign in to comment.