Skip to content

Commit

Permalink
fix: sticky header on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
gion-andri committed Dec 8, 2023
1 parent 314990d commit e114f2c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,16 @@
}
}

&.touchesTop:not(.first) {
border-top: none;
}

@include media-breakpoint-up(md) {
h2 {
font-size: 1.5rem;
margin: 1rem 2rem;
}

&.touchesTop:not(.first) {
border-top: none;
}
&.isOnTop {
border-top: none;
}
Expand All @@ -114,8 +115,9 @@
}

ul {
padding: 0 1rem;
list-style: none;
margin-bottom: 0;
padding: 0 1rem 1rem;;

@include media-breakpoint-up(md) {
padding: 2rem;
Expand Down
8 changes: 7 additions & 1 deletion src/app/shared/directives/scrollable-title.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,20 @@ export class ScrollableTitleDirective implements OnInit, OnDestroy {

private _checkScroll() {
if (isPlatformBrowser(this.platformId)) {
const width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
const {
top: t,
} = this.el.nativeElement.getBoundingClientRect();
const {
scrollX,
} = window
const topPos = t + scrollX
this.touchesTop = topPos <= 75;

if (width < 768) {
this.touchesTop = topPos <= 54;
} else {
this.touchesTop = topPos <= 75;
}
this.isOnTop = topPos < 1;
this.startsHiding = topPos < 0;
}
Expand Down

0 comments on commit e114f2c

Please sign in to comment.