1
1
<template >
2
- <img alt =" Vue logo" src =" ./assets/logo.png" >
3
- <HelloWorld msg =" Welcome to Your Vue.js App" />
2
+ <div class =" grid-cntr" >
3
+ <button
4
+ class =" btn"
5
+ @touchstart =" nameCurrentEvent('touchstart')"
6
+ @touchmove =" nameCurrentEvent('touchmove')"
7
+ @touchend =" nameCurrentEvent('touchend')"
8
+ >Touch me</button
9
+ >
10
+ <button class =" btn" v-touch:tap =" onTapItem('onTapItem')" >Tap me</button >
11
+ <button class =" btn" v-touch:swipe =" onSwipeItem" >Swipe any direction</button >
12
+ <button class =" btn" v-touch:swipe.left =" onSwipeLeftItem" >Swipe left</button >
13
+ <button class =" btn" v-touch:drag =" onDragItem" >Drag me</button >
14
+ <button class =" btn" v-touch:press =" onPressItem" >Press me</button ></div
15
+ >
16
+
17
+ <p class =" output"
18
+ >Current Touch Event:
19
+ <span class =" event" >{{ name }}</span >
20
+ </p >
4
21
</template >
5
22
6
23
<script >
7
- import HelloWorld from ' ./components/HelloWorld.vue'
8
-
9
24
export default {
10
- name: ' App' ,
11
- components: {
12
- HelloWorld
13
- }
14
- }
25
+ name: " App" ,
26
+ data () {
27
+ return {
28
+ name: " none" ,
29
+ };
30
+ },
31
+ methods: {
32
+ nameCurrentEvent (name ) {
33
+ this .name = name;
34
+ },
35
+ onTapItem (param ) {
36
+ return function () {
37
+ alert (" You called the " + param + " touch event." );
38
+ };
39
+ },
40
+ onSwipeItem () {
41
+ return (this .name = " swipped" );
42
+ },
43
+ onSwipeLeftItem () {
44
+ return (this .name = " swipped left" );
45
+ },
46
+ onDragItem () {
47
+ return (this .name = " dragged" );
48
+ },
49
+ onPressItem () {
50
+ return (this .name = " pressed" );
51
+ },
52
+ },
53
+ };
15
54
</script >
16
55
17
56
<style >
@@ -23,4 +62,25 @@ export default {
23
62
color : #2c3e50 ;
24
63
margin-top : 60px ;
25
64
}
65
+ .grid-cntr {
66
+ display : grid ;
67
+ grid-template-columns : 1fr 1fr 1fr ;
68
+ max-width : 500px ;
69
+ margin : auto ;
70
+ }
71
+ .btn {
72
+ border : 2px solid rgb (71 , 197 , 255 );
73
+ background-color : rgb (246 , 244 , 244 );
74
+ border-radius : 5px ;
75
+ height : 100px ;
76
+ font-size : 1rem ;
77
+ margin : 10px ;
78
+ display : flex ;
79
+ align-items : center ;
80
+ justify-content : center ;
81
+ }
82
+ .event {
83
+ border-bottom : 1px solid rgb (71 , 197 , 255 );
84
+ color : rgb (113 , 113 , 113 );
85
+ }
26
86
</style >
0 commit comments