Ionic 2对手势事件的辩护

时间:2017-03-21 15:41:35

标签: angular ionic2 rxjs

如何将Rx / Js指责绑定到离子2手势事件?

        this.pressGesture = new Gesture(this.content._elementRef.nativeElement);
        this.pressGesture.listen();
        this.pressGesture.on('pinch', e => { 
            console.log('testing');
        });

1 个答案:

答案 0 :(得分:2)

你正在寻找这样的东西:

const pinch = Observable.fromEvent(this.pressGesture, 'pinch')
  .debounceTime(500);

fromEvent方法接受符合标准EventEmitter类似接口的类型,因此能够使用on方法自动绑定事件。这会将Gesture对象提升为流,并允许您在其上使用标准的RxJS运算符。