Skip to content

Commit

Permalink
fix: fix scroll issue
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Mar 18, 2020
1 parent 2af5a0c commit 7205352
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,13 @@ export class MarkdownRenderComponent implements OnInit, OnChanges, AfterViewInit

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

scrollToTop() {
(function smoothscroll() {
const currentScroll = document.documentElement.scrollTop || document.body.scrollTop;
if (currentScroll > 0) {
window.requestAnimationFrame(smoothscroll);
window.scrollTo(0, currentScroll - (currentScroll / 8));
}
})();
window.scrollTo({top: 0, left: 0, behavior: 'smooth'});
}

ngOnInit(): void {
Expand Down
2 changes: 2 additions & 0 deletions src/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ html, body { height: 100%; }
margin: 0;
padding: 0;
}

html {
overflow: scroll;
overflow-x: hidden;

scroll-behavior: smooth;
//overscroll-behavior-y: contain;
}

::-webkit-scrollbar {
Expand Down

0 comments on commit 7205352

Please sign in to comment.