[NOT MAINTAINED] This project is discontinued respectively I don't maintain it anymore.
ionic-swing is a fork of the following projects intended to add the swipeable cards capatibilies to Ionic (>= 2)
To install this library, run:
$ npm install ionic-swing --saveIn your app.module.ts, import the library like following:
import {IonicSwingModule} from 'ionic-swing';
and add it to your imports:
imports: [
...
IonicSwingModule
...
]
To implement a card stack, follow the example provided by angular2-swing https://github.com/ksachdeva/angular2-swing
Or you could find also another example in my mobile application Fluster, see the following page and module https://github.com/fluster/fluster-app/tree/master/src/app/pages/browse/items/items
In Ionic v4, in order to access the stack and cards as ViewChild and ViewChildren, it's mandatory to use the keyword read to identify correctly the elements
Html:
<div swingStack #swingStack>
<ion-card swingCard #swingCards>
</ion-card>
</div>
Ts:
@ViewChild('swingStack', {read: SwingStackDirective}) swingStack: SwingStackDirective;
@ViewChildren('swingCards', {read: SwingCardDirective}) swingCards: QueryList<SwingCardDirective>;
This library need hammerjs but isn't shipped with it because some framework, like Ionic v3, already include it in their own resources. If it isn't your case, you would need to install hammerjs in your project
$ npm install hammerjs --saveand add the following line to your app.component.ts
import 'hammerjs';
If you would face the error ReferenceError: global is not defined at ionic-swing.js at runtime, this could be fixed by declaring the window to the global scope. To do so add you could add the following to your polyfill.ts:
(window as any).global = window;
To generate the library using ng-packagr (https://github.com/dherges/ng-packagr)
$ npm run packagrTo test locally
$ cd dist
$ npm pack
$ cd /your-project-path/
$ npm install /relative-path-to-local-ionic-swing/dist/ionic-swing-0.0.0.tgzMIT © David Dal Busco