项目作者: toriphes

项目描述 :
Change header background opacity on content scroll
高级语言: TypeScript
项目地址: git://github.com/toriphes/ion-header-scroll-opacity.git
创建时间: 2018-06-13T21:10:00Z
项目社区:https://github.com/toriphes/ion-header-scroll-opacity

开源协议:MIT License

下载


npm
npm
npm

ion-header-scroll-opacity

Now compatible with Ionic 4 🎉.

Change header background opacity on content scroll.

install

  1. npm i ion-header-scroll-opacity --save

If you are using Ionic 3 install ion-header-scroll-opacity@^1.0.0 and use to the ion-header-scroll-opacit#ionic-3 branch for reference.

Import directive

Import the IonHeaderScrollOpacityModule into the your page module

  1. import { IonHeaderScrollOpacityModule } from "ion-header-scroll-opacity";
  2. @NgModule({
  3. [...]
  4. imports: [IonHeaderScrollOpacityModule],
  5. [...]
  6. })
  7. export class HomePageModule {}

Usage

Put the header-scroll-opacity directive on the ion-header element.

Directive Input

Input Description Default value
ionContentRef ion-content reference none
scrollAmount Amount of pixel to be scrolled in order end the opacity transition 88
isTransparent If true the header background starts with opacity=0 true
  1. <ion-header scrollOpacity [ionContentRef]="mycontent">
  2. <ion-toolbar color="primary">
  3. <ion-title>
  4. Do scroll
  5. </ion-title>
  6. </ion-toolbar>
  7. </ion-header>
  8. <ion-content #mycontent [scrollEvents]="true">
  9. ...long scrolling content...
  10. </ion-content>

Remember to set [scrollEvents]="true" on the ion-content component otherwise the directive will not work.

Tip

Add the fullscreen attribute to the ion-content element and add some css style to make a good effect

  1. .scroll-content {
  2. padding-top: 0px !important;
  3. }

Demo

Demo

Contribute

Any pull-request and issues are wellcome