离子pinchin和pinchout手势似乎不适用于android

时间:2017-08-31 15:04:15

标签: android ios ionic2 hammer.js gestures

这是我的捏区。

<div class="pinch-div" #pinchDiv></div>

相关属性

gesture: Gesture;
@ViewChild('pinchDiv') element;

初​​始化

this.angle = 15;
this.gesture = new Gesture(this.element.nativeElement);
this.gesture.listen();
//this.gesture.on('pinch', e => this.pinchEvent(e, this.angle));

this.gesture.on('pinchin', e => this.pinchInEvent(e, this.angle));
this.gesture.on('pinchout', e => this.pinchOutEvent(e, this.angle));

功能

    pinchEvent(event, angle){
        console.log('pinch event detected');
        angle += 3;

        if(angle > 215){
            angle = 215
        }

        if(angle < 15){
            angle = 15;
        }

        console.log(angle);
        this.angleChanged.next(angle);
    }

    pinchInEvent(event, angle){
        if(angle >= 15){
            angle -= 3;
        }
        this.angleChanged.next(angle);
    }

    pinchOutEvent(event, angle){
        if(angle <= 215){
            angle += 3;
        }
        this.angleChanged.next(angle);
    }

观察

即使在收缩区内按下两根手指,

pinchEvent()也会在 android 中触发。如果我在#pinchDiv中握住两根手指,我会检测到一堆“捏合事件”。日志。我不认为按住两根手指是一种捏。然而,在评论出这一行并且只听“捏”&#39;和&#39; pinchout&#39;,我的pinchInEvent()和pinchOutEvent()不会在各自的手势上触发。 另一方面,没有观察到pinchEvent()仅在两个手指上发射的奇怪行为,并且“pinchin”&#39;和&#39; pinchout&#39;在 IOS 中被解雇了。我不确定是否有一些我需要添加的怪癖。我只是在寻找一些方向和建议。

0 个答案:

没有答案