Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect multi finger touch in ionic app

I am developing an Ionic app.In that I want to apply 1 finger swipe and 2 finger swipe and 3 finger swipe ( If it is possible ). In a div if user swipes with single finger, it should scroll and If user swipes with multi finger , it should select the content and select,copy options should be shown and 3 finger swipe for one more action.

edit: I checked the question before posting this question.I am able to detect multi touch but not 2finger / 3 finger swipe. I am looking for any plugins for this actions.

Help me in this issue.

like image 833
varun aaruru Avatar asked Jan 07 '16 08:01

varun aaruru


1 Answers

Look how 4-touch for reload is implemented in the Phonegap Developer App:

var currentTouches = {},
    eventName = { touchstart: 'touchstart', touchend: 'touchend' };

if (window.navigator.msPointerEnabled) {
    eventName = { touchstart: 'MSPointerDown', touchend: 'MSPointerUp' };
}

document.addEventListener(eventName.touchstart, function(evt) {
    var touches = evt.touches || [evt],
        touch;
    for(var i = 0, l = touches.length; i < l; i++) {
        touch = touches[i];
        currentTouches[touch.identifier || touch.pointerId] = touch;
    }
});

document.addEventListener(eventName.touchend, function(evt) {
    var touchCount = Object.keys(currentTouches).length;
    currentTouches = {};
    if (touchCount === 4) {
        evt.preventDefault();
        window.location.reload(true);
    }
}, false);

Hope this helps.

like image 189
daserge Avatar answered Oct 18 '22 15:10

daserge