toennito icon

Swipe-Button

toennito | PRO | 05/08/16 09:23:25 AM UTC | 0 ⭐ | 10144 👁️ | Never ⏰ | []
Dart |

1.08 KB

|

None

|

0 👍

/

0 👎

  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

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎