Skip to content

Commit

Permalink
refactor: remove unused top code
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Apr 4, 2020
1 parent 4ffe6f1 commit e52cfa5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</div>
</div>
<div class="right-content">
<ledge-render [content]="data" *ngIf="data" (scroll)="handleScroll()"></ledge-render>
<ledge-render [content]="data" *ngIf="data" (scroll)="handleScroll($event)"></ledge-render>
</div>
</div>
</div>
Expand Down
21 changes: 5 additions & 16 deletions src/app/features/markdown-render/markdown-render.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,37 +74,26 @@ export class MarkdownRenderComponent
onResize(event) {}

@HostListener('window:scroll', ['$event'])
handleScroll() {
let top = 0;
if (this.drawerEl && this.drawerEl.nativeElement) {
top = this.drawerEl.nativeElement.scrollTop;
}

handleScroll(event) {
const windowScroll = window.pageYOffset;
const headerHeight = 64;
if (windowScroll >= headerHeight) {
this.sticky = true;
} else {
this.sticky = false;
}
this.sticky = windowScroll >= headerHeight;

if (
window.pageYOffset ||
document.documentElement.scrollTop ||
document.body.scrollTop ||
top > 64
document.body.scrollTop
) {
this.windowScrolled = true;
} else if (
(this.windowScrolled && window.pageYOffset) ||
document.documentElement.scrollTop ||
document.body.scrollTop ||
top < 10
document.body.scrollTop
) {
this.windowScrolled = false;
}

this.handleForMenuSync(top);
this.handleForMenuSync(windowScroll);
}

private handleForMenuSync(top: number) {
Expand Down

0 comments on commit e52cfa5

Please sign in to comment.