All Projects → jonaszuberbuehler → Ion Affix

jonaszuberbuehler / Ion Affix

Licence: mit
A directive for Ionic framework for creating affix headers.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Ion Affix

fireblogger
Ionic 2 social media microblogging platform built with firebase 3 as backend
Stars: ✭ 54 (-6.9%)
Mutual labels:  ionic, ionic-framework, ionic2, ionic3
Awesome Ionic
An "awesome" list of Ionic resources
Stars: ✭ 799 (+1277.59%)
Mutual labels:  ionic, ionic-framework, ionic3, ionic2
ionic-uber-clone
Ionic 4 Taxi Booking script
Stars: ✭ 34 (-41.38%)
Mutual labels:  ionic, ionic-framework, ionic2, ionic3
todo-list
TodoList using Ionic2/3 & Firebase: * PWA * SSO Google plus. * Share list via QRcode. * Upload image from Camera or Storage. * Speech Recognition.
Stars: ✭ 18 (-68.97%)
Mutual labels:  ionic, ionic-framework, ionic2, ionic3
ionic-socialsharing-with-deeplinking-example
Ionic Social Sharing and Deep Linking example app. Complete Ionic Tutorial with free example app! Built for Ionic 3.
Stars: ✭ 16 (-72.41%)
Mutual labels:  ionic, ionic-framework, ionic2, ionic3
ionic3
This repository contains complete source code for Ionic 3 tutorial from https://ampersandacademy.com/tutorials/ionic-framework-3. I will try many Ionic 3 specific scripts and will write them as separate tutorial. You can follow this repo to get more tested and working script for the Ionic 3.
Stars: ✭ 21 (-63.79%)
Mutual labels:  ionic, ionic-framework, ionic2, ionic3
Wooionic3
An eCommerce App for WooCommerce stores using Ionic 3.
Stars: ✭ 208 (+258.62%)
Mutual labels:  ionic, ionic-framework, ionic3, ionic2
ionicfirebaseauth
Exemplo de alguns tipos de autenticação com Ionic 2 e Firebase
Stars: ✭ 18 (-68.97%)
Mutual labels:  ionic, ionic-framework, ionic2, ionic3
ionic-modal-custom-transitions
Add Custom Transitions to Ionic Modals.
Stars: ✭ 22 (-62.07%)
Mutual labels:  ionic, ionic-framework, ionic2, ionic3
ionic3-image-handling
In this ionic tutorial you will learn how to access the image gallery and take pictures from an ionic app. Also we will show you how to add a image cropper. This ionic tutorial includes a working ionic app example you can reuse for your needs.
Stars: ✭ 35 (-39.66%)
Mutual labels:  ionic, ionic-framework, ionic2, ionic3
ionic-hockeyapp
Need HockeyApp in your Ionic application, add this package!
Stars: ✭ 19 (-67.24%)
Mutual labels:  ionic, ionic-framework, ionic2, ionic3
ionic-3-video-calling-using-webrtc
This is demo code of how to implement video calling in ionic 3 using webrtc
Stars: ✭ 58 (+0%)
Mutual labels:  ionic, ionic-framework, ionic2, ionic3
Ionic Audio
An audio player for Ionic 3 and Angular 4. Works with HTML 5 audio or native audio using Cordova Media plugin.
Stars: ✭ 332 (+472.41%)
Mutual labels:  ionic-framework, ionic3, ionic2
Ionic2 Calendar
A calendar component based on Ionic framework
Stars: ✭ 338 (+482.76%)
Mutual labels:  ionic, ionic3, ionic2
angular-progress-bar
This component allow you to easy incorporate progress-bar to angular/ionic project, providing binding and color options
Stars: ✭ 26 (-55.17%)
Mutual labels:  ionic, ionic2, ionic3
Ionic3 Chat
ionic3 chat example
Stars: ✭ 465 (+701.72%)
Mutual labels:  ionic, ionic3, ionic2
ionic-uuchat
基于ionic3,angular4的实时聊天app,兼容web端。该项目只是前端部分,所有数据需要请求后端服务器,需要配套express-uuchat-api使用。
Stars: ✭ 14 (-75.86%)
Mutual labels:  ionic, ionic2, ionic3
cordova-plugin-today-widget
Add a today widget app extension target to your cordova project.
Stars: ✭ 51 (-12.07%)
Mutual labels:  ionic, ionic2, ionic3
ionic-native-sms-retriever-plugin-master
Cross-platform plugin for Cordova / PhoneGap to Retrieve SMS. Available for Android.
Stars: ✭ 16 (-72.41%)
Mutual labels:  ionic, ionic-framework, ionic3
Ion2 Calendar
📅 A date picker components for ionic2 /ionic3 / ionic4
Stars: ✭ 537 (+825.86%)
Mutual labels:  ionic, ionic3, ionic2

npm npm npm npm

ion-affix

Allows for creating affixed (sticky) ion-list-header, ion-item-divider and ion-card for newest Ionic framework.

Kudos to Collin Donahue-Oponski and his initial idea shown in this gist.

See it

Here, the source can be found at https://github.com/jonaszuberbuehler/ion-affix-demo.

Get it

from npm

npm install --save ion-affix

Use it

Import IonAffixModule in your app.module.ts

@NgModule({
    ...
    imports: [
        IonAffixModule
    ]
    ...
})
export class AppModule {
}

and add the directive ion-affix to any ion-list-header, ion-item-divider or ion-item (inside ion-card) that should be sticky. You also need to provide a reference to the parent ion-content.

<ion-content padding #content>
   <ion-list>
       <ion-list-header ion-affix [content]="content" (click)="test()">Group 1</ion-list-header>
       <ion-item *ngFor="let item of items">{{item}}</ion-item>
   </ion-list>
   <ion-list>
       <ion-list-header ion-affix [content]="content">Group 2</ion-list-header>
       <ion-item *ngFor="let item of items">{{item}}</ion-item>
   </ion-list>
</ion-content>
<ion-content padding #content>
   <ion-item-group>
       <ion-item-divider ion-affix [content]="content" (click)="test()">Group 1 (click me!)</ion-item-divider>
       <ion-item *ngFor="let item of items">{{item}}</ion-item>
   </ion-item-group>
   <ion-item-group>
       <ion-item-divider ion-affix [content]="content">Group 2</ion-item-divider>
       <ion-item *ngFor="let item of items">{{item}}</ion-item>
   </ion-item-group>
</ion-content>
<ion-content padding #content>
    <ion-card>
        <ion-item ion-affix [content]="content" no-lines>
            <ion-avatar item-start>
                <img src="assets/img/marty-avatar.png">
            </ion-avatar>
            <h2>Marty McFly</h2>
            <p>November 5, 1955</p>
        </ion-item>
        <img src="assets/img/advance-card-bttf.png">
        <ion-card-content>
            <p>Wait a minute. Wait a minute, Doc. Uhhh... Are you telling me that you built a time machine... out of a DeLorean?! Whoa. This is heavy.</p>
        </ion-card-content>
        <ion-row>
            <ion-col>
                <button ion-button color="primary" clear small icon-start>
                    <ion-icon name='thumbs-up'></ion-icon>
                    12 Likes
                </button>
            </ion-col>
            <ion-col>
                <button ion-button color="primary" clear small icon-start>
                    <ion-icon name='text'></ion-icon>
                    4 Comments
                </button>
            </ion-col>
            <ion-col align-self-center text-center>
                <ion-note>
                    11h ago
                </ion-note>
            </ion-col>
        </ion-row>
    </ion-card>
</ion-content>

ion-scroll

If you need sticky headers within an ion-scroll make sure you're using a version of this module >=1.1.0 and pass the reference of it instead of ion-content. You most likely also want to add style="overflow:hidden" to the ion-scroll, otherwise the pushing up/pulling down of headers looks a bit strange.

Events

In case you need to know whether a certain element gets sticky or not you can subscribe to onSticky(IonAffixEvent) event:

<ion-content padding #content>
   <ion-list>
       <ion-list-header ion-affix [content]="content" (onSticky)="handleOnSticky($event)">Group 1</ion-list-header>
       <ion-item *ngFor="let item of items">{{item}}</ion-item>
   </ion-list>
   <ion-list>
       <ion-list-header ion-affix [content]="content">Group 2</ion-list-header>
       <ion-item *ngFor="let item of items">{{item}}</ion-item>
   </ion-list>
</ion-content>

IonAffixEvent has two properties:

sticky

(boolean) Whether the affix is sticky or not.

affix

(IonAffix) The affected element (in case you need to manipulate it).

Explain it

To be able use custom Angular directives on a sticky header I decided to make the original ion-list-header element sticky instead of its clone. This is the major difference to the gist shown above and I did it mainly because I have no idea how to do a $compile(clone) known from AngularJS with Angular 2.

Note it

To make it work on iOS use the cordova-plugin-wkwebview-engine plugin. Otherwise the scroll events are only fired once scrolling stops.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].