Skip to content

Commit 2da570d

Browse files
author
vakrilov
committed
Gestures snippets
1 parent bab26bb commit 2da570d

File tree

3 files changed

+100
-0
lines changed

3 files changed

+100
-0
lines changed

tests/app/main.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// this import should be first in order to load some required settings (like globals and reflect-metadata)
22
import {nativeScriptBootstrap} from "nativescript-angular/application";
33
import {AppComponent} from "./app.component";
4+
import {GestureComponent} from "./snippets/gestures.component";
45

56
nativeScriptBootstrap(AppComponent);
7+
// nativeScriptBootstrap(GestureComponent);
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<StackLayout orientation="vertical">
2+
<!-- >> tap-gesture -->
3+
<Label text="Tap here" (tap)="onTap($event)"></Label>
4+
<!-- << tap-gesture -->
5+
6+
<!-- >> double-tap-gesture -->
7+
<Label text="Double tap here" (doubleTap)="onDoubleTap($event)"></Label>
8+
<!-- << double-tap-gesture -->
9+
10+
<!-- >> long-press-gesture -->
11+
<Label text="Long press here" (longPress)="onLongPress($event)"></Label>
12+
<!-- << long-press-gesture -->
13+
14+
<!-- >> swipe-gesture -->
15+
<Label text="Swipe here" (swipe)="onSwipe($event)"></Label>
16+
<!-- << swipe-gesture -->
17+
18+
<!-- >> pan-gesture -->
19+
<Label text="Pan here" (pan)="onPan($event)"></Label>
20+
<!-- << pan-gesture -->
21+
22+
<!-- >> pinch-gesture -->
23+
<Label text="Pinch here" (pinch)="onPinch($event)"></Label>
24+
<!-- << pinch-gesture -->
25+
26+
<!-- >> rotate-gesture -->
27+
<Label text="Rotate here" (rotation)="onRotate($event)"></Label>
28+
<!-- << rotate-gesture -->
29+
30+
<!-- >> touch-gesture -->
31+
<Label text="Touch here" (touch)="onTouch($event)"></Label>
32+
<!-- << touch-gesture -->
33+
</StackLayout>

0 commit comments

Comments
 (0)