向上/向下滑动不能使用Ionic 2 [英] Swipe up/down not working on Ionic 2
本文介绍了向上/向下滑动不能使用Ionic 2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用Ionic 2使用向上滑动
或向下滑动
?
How can I use swipe up
or swipe down
with Ionic 2?
我已经尝试了手势API ,但它只是水平滑动时触发。
I've tried the Gestures API but it only fires on horizontal swipe.
<ion-card (swipe)="swipePage($event)">
</ion-card>
推荐答案
在HammerJS官方文件中,底线是:
In the HammerJS official document, bottom line says :
当调用Hammer()来创建一个简单实例时,平移和滑动
识别器被配置为仅检测水平手势。 / p>
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 :
首次运行
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
}]
这篇关于向上/向下滑动不能使用Ionic 2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文