Skip to content
This repository has been archived by the owner on May 25, 2021. It is now read-only.

fixes #511 #512

Merged
merged 1 commit into from
Aug 5, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/frontend/components/component-tree/component-tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ export class ComponentTree {
scrollToViewIfNeeded(node) {
const selectedNodeBound = node.getBoundingClientRect();
const treeViewBound = this.el.nativeElement.getBoundingClientRect();
const scrollBarHeight = this.el.nativeElement.offsetHeight -
this.el.nativeElement.clientHeight;
const topOffset = selectedNodeBound.top - treeViewBound.top;
const bottomOffset = selectedNodeBound.bottom - treeViewBound.bottom;
const bottomOffset = selectedNodeBound.bottom - treeViewBound.bottom +
scrollBarHeight;

if (topOffset < 0) { // node is too high
this.el.nativeElement.scrollTop += topOffset;
} else if (bottomOffset > 0) { // node is too low
Expand Down