Created
September 11, 2018 12:47
-
-
Save paulstelzer/cca1aa1a8669e985dbfa0bfd262093eb to your computer and use it in GitHub Desktop.
Ionic 4 Transparent Header
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ion-header> | |
<ion-toolbar color="secondary" [class.show-background]="showToolbar"> | |
<ion-buttons slot="start"> | |
<ion-menu-button></ion-menu-button> | |
</ion-buttons> | |
<ion-buttons slot="end"> | |
<ion-button> | |
<ion-icon slot="icon-only" name="logo-facebook"></ion-icon> | |
</ion-button> | |
</ion-buttons> | |
</ion-toolbar> | |
</ion-header> | |
<ion-content fullscreen (ionScroll)="onScroll($event)" [scrollEvents]="true"> | |
Your content here! | |
</ion-content> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Transparent standard */ | |
ion-toolbar { | |
--background: transparent; | |
--ion-color-base: transparent !important; | |
} | |
/* Show background if class is active */ | |
.show-background { | |
border-style: none; | |
background: var(--ion-color-primary); | |
} | |
/* Remove bottom border on md */ | |
.header-md::after { | |
background-image: none; | |
} | |
/* Remove bottom border on ios */ | |
.header-ios ion-toolbar:last-child { | |
--border-width: 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ScrollDetail } from '@ionic/core'; | |
showToolbar = false; | |
onScroll($event: CustomEvent<ScrollDetail>) { | |
if ($event && $event.detail && $event.detail.scrollTop) { | |
const scrollTop = $event.detail.scrollTop; | |
this.showToolbar = scrollTop >= 225; | |
} | |
} |
Thanks 👍
Thanks 👍
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👍