Make desktop docs-nav sticky on scroll

This commit is contained in:
hunicus 2021-12-15 21:31:00 -05:00
parent 40f1949654
commit 3ae46e6ba1
No known key found for this signature in database
GPG Key ID: 24837C51B6D81FD9
3 changed files with 22 additions and 2 deletions

View File

@ -3,8 +3,8 @@
<div id="restAPI" *ngIf="restTabActivated">
<div class="doc-nav-desktop">
<p>Placeholder.</p>
<div class="doc-nav-desktop" [ngClass]="docsNavPosition">
Placeholder.
</div>
<div class="doc-content">

View File

@ -74,9 +74,18 @@ li.nav-item {
.doc-nav-desktop {
width: 25%;
}
.doc-nav-desktop.relative {
float: left;
}
.doc-nav-desktop.fixed {
float: unset;
position: fixed;
top: 20px;
}
.doc-content {
width: 75%;
float: right;

View File

@ -17,6 +17,7 @@ export class ApiDocsComponent implements OnInit {
code: any;
baseNetworkUrl = '';
@Input() restTabActivated: Boolean;
docsNavPosition = "relative";
constructor(
private stateService: StateService,
@ -35,6 +36,16 @@ export class ApiDocsComponent implements OnInit {
})
);
//to toggle fixed menu for desktop navigation
let that = this;
window.addEventListener('scroll', function() {
if( window.pageYOffset > 182 ) {
that.docsNavPosition = "fixed";
} else {
that.docsNavPosition = "relative";
}
});
if (document.location.port !== '') {
this.hostname = `${this.hostname}:${document.location.port}`;
}