summaryrefstree
path: root/usr/bin/qml/Reminder/HMISwipeArea.qml
blob: b24108d073343b2eb4a16bd669b6c79bb41f52d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import QtQuick 2.0
import "../com/neusoft/auto/widgets"

MouseArea {

    property var threshold;

    signal swipeRight;
    signal swipeLeft;
//    signal swipeUp;
//    signal swipeDown;

    property int startX;
//    property int startY;

    onPressed: {
        startX = mouse.x;
//        console.log("[HMISwipeArea][onReleased]-->startX:",startX);
//        startY = mouse.y;
    }

    onReleased: {
//    var deltax = mouse.x - startX;
//    var deltay = mouse.y - startY;

//        if (Math.abs(deltax) > 50 || Math.abs(deltay) > 50) {
//            if (deltax > 30 && Math.abs(deltay) < 30) {
//                // swipe right
//                swipeRight();
//            } else if (deltax < -30 && Math.abs(deltay) < 30) {
//                // swipe left
//                swipeLeft();
//            } else if (Math.abs(deltax) < 30 && deltay > 30) {
//                // swipe down
//            swipeDown();
//            } else if (Math.abs(deltax) < 30 && deltay < 30) {
//                // swipe up
//                swipeUp();
//            }
//        }
        var deltax = mouse.x - startX;
//        console.log("[HMISwipeArea][onReleased]-->deltax:",deltax);
            if (deltax > threshold){
                swipeRight();
            }else if(deltax < -threshold){
                swipeLeft();
            }
    }

    /*========================================Function Start==============================================*/
    function swipePressed(mouse_x){
        startX = mouse_x;
    }

    function swipeReleased(mouse_x){
        var deltax = mouse_x - threshold;
        if (deltax > 30){
            swipeRight();
        }else if(deltax < -threshold){
            swipeLeft();
        }
    }
    /*========================================Function End================================================*/
}