final Element p = querySelector('#sniffer');
int act1X, act1XStart, act1Y, act1YStart, diffX, diffY;
String action1 = "1";
querySelector("#action1")
..onTouchStart.listen((TouchEvent e) {
act1XStart = e.touches.first.page.x;
act1YStart = e.touches.first.page.y;
act1X = e.touches.last.page.x;
act1Y = e.touches.last.page.y;
})
..onTouchMove.listen((TouchEvent e) {
act1X = e.touches.last.page.x;
act1Y = e.touches.last.page.y;
})
..onTouchEnd.listen((TouchEvent e) {
diffX = act1X - act1XStart;
diffY = act1Y - act1YStart;
if (diffX.abs() < 10 && diffY.abs() < 10) {
print("ACTION $action1");
p.appendText(action1);
} else if (diffX.abs() < diffY.abs()) {
if (diffY.isNegative) {
action1 = "1";
} else {
action1 = "3";
}
} else {
if (diffX.isNegative) {
action1 = "4";
} else {
action1 = "2";
}
}
querySelector("#action1").setAttribute("value", action1);
});
Comments
0 B
|👍
/👎
0 B
|👍
/👎