1+ import { Component } from "angular2/core" ;
2+ import {
3+ GestureEventData ,
4+ PanGestureEventData ,
5+ PinchGestureEventData ,
6+ RotationGestureEventData ,
7+ SwipeGestureEventData ,
8+ TouchGestureEventData } from "ui/gestures" ;
9+
10+ @Component ( {
11+ selector : "gestures" ,
12+ templateUrl : "snippets/gestures.component.xml" ,
13+ styles :[ 'label { font-size: 32; margin: 2; background-color: lightgreen;}' ]
14+ } )
15+ export class GestureComponent {
16+
17+ // >> tap-gesture
18+ onTap ( args : GestureEventData ) {
19+ console . log ( "Tap!" )
20+ }
21+ // << tap-gesture
22+
23+ // >> double-tap-gesture
24+ onDoubleTap ( args : GestureEventData ) {
25+ console . log ( "DoubleTap!" )
26+
27+ }
28+ // << double-tap-gesture
29+
30+ // >> long-press-gesture
31+ onLongPress ( args : GestureEventData ) {
32+ console . log ( "LongPress!" )
33+ }
34+ // << long-press-gesture
35+
36+ // >> swipe-gesture
37+ onSwipe ( args : SwipeGestureEventData ) {
38+ console . log ( "Swipe Direction: " + args . direction ) ;
39+ }
40+ // << swipe-gesture
41+
42+ // >> pan-gesture
43+ onPan ( args : PanGestureEventData ) {
44+ console . log ( "Pan delta: [" + args . deltaX + ", " + args . deltaY + "] state: " + args . state ) ;
45+ }
46+ // << pan-gesture
47+
48+ // >> pinch-gesture
49+ onPinch ( args : PinchGestureEventData ) {
50+ console . log ( "Pinch scale: " + args . scale + " state: " + args . state ) ;
51+ }
52+ // << pinch-gesture
53+
54+ // >> rotate-gesture
55+ onRotate ( args : RotationGestureEventData ) {
56+ console . log ( "Rotate angle: " + args . rotation + " state: " + args . state ) ;
57+ }
58+ // << rotate-gesture
59+
60+ // >> touch-gesture
61+ onTouch ( args : TouchGestureEventData ) {
62+ console . log ( "Touch point: [" + args . getX ( ) + ", " + args . getY ( ) + "] activePointers: " + args . getActivePointers ( ) . length ) ;
63+ }
64+ // << touch-gesture
65+ }
0 commit comments