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

Commit

Permalink
Merge pull request #512 from rangle/scrollbar-fix
Browse files Browse the repository at this point in the history
fixes #511
  • Loading branch information
Andrew Lo committed Aug 5, 2016
2 parents 2ef7ff8 + db79690 commit a72bf0c
Showing 1 changed file with 5 additions and 1 deletion.
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

0 comments on commit a72bf0c

Please sign in to comment.