How can I use swipe up or swipe down with Ionic 2?
I've tried the Gestures API but it only fires on horizontal swipe.
<ion-card (swipe)="swipePage($event)">
</ion-card>
In the HammerJS official document, bottom line says :
When calling Hammer() to create a simple instance, the pan and swipe recognizers are configured to only detect horizontal gestures.
For additional config, you must tweak your hammer instance, try this :
First run
npm install hammerjs --save && npm install @types/hammerjs --save-dev
import { HammerGestureConfig, HAMMER_GESTURE_CONFIG } from '@angular/platform-browser';
import * as Hammer from 'hammerjs';
// create a class that overrides hammer default config
export class MyHammerConfig extends HammerGestureConfig {
overrides = <any>{
'swipe': { direction: Hammer.DIRECTION_ALL } // override default settings
}
}
// In your module providers, add this :
providers: [{
provide: HAMMER_GESTURE_CONFIG,
useClass: MyHammerConfig
}]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With