Skip to content

Commit

Permalink
fix: addd basic scrollbar
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Apr 3, 2020
1 parent d7f2481 commit ac73364
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
1 change: 0 additions & 1 deletion src/app/presentation/solution/solution.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
.left-drawer {
width: 15%;
min-width: 200px;
min-height: 100vh;

h2 {
padding: 20px 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</div>

<div *ngIf="!showToc" class="no-toc-markdown">
<ledge-render (scroll)="handleScroll()" [content]="data" *ngIf="data"></ledge-render>
<ledge-render [content]="data" *ngIf="data"></ledge-render>
</div>

<!--Scroll to top-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
.left-drawer {
width: 15%;
min-width: 120px;
min-height: 100vh;
}

.right-content {
height: calc(100vh - 68px);
}
}

Expand All @@ -20,8 +20,9 @@

.sticky {
position: fixed;
overflow: hidden;
overflow: scroll;
z-index: 10;
height: calc(100vh - 66px);
}

.scroll-to-top {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class MarkdownRenderComponent
data = '';

@ViewChild('toc', { static: false }) tocEl: ElementRef;
@ViewChild('drawerContent', { static: false }) drawerEl: any;
@ViewChild('drawerContent', { static: false }) drawerEl: ElementRef;

loading = this.data !== '';

Expand Down Expand Up @@ -76,8 +76,8 @@ export class MarkdownRenderComponent
@HostListener('window:scroll', ['$event'])
handleScroll() {
let top = 0;
if (this.drawerEl) {
top = this.drawerEl.elementRef.nativeElement.scrollTop;
if (this.drawerEl && this.drawerEl.nativeElement) {
top = this.drawerEl.nativeElement.scrollTop;
}

const windowScroll = window.pageYOffset;
Expand Down Expand Up @@ -135,8 +135,8 @@ export class MarkdownRenderComponent

scrollToTop() {
window.scrollTo({ top: 0, left: 0, behavior: 'smooth' });
if (this.drawerEl) {
this.drawerEl.elementRef.nativeElement.scrollTop = 0;
if (this.drawerEl && this.drawerEl.nativeElement) {
this.drawerEl.nativeElement.scrollTop = 0;
}
}

Expand Down

0 comments on commit ac73364

Please sign in to comment.