Skip to content

Commit 813ca56

Browse files
committed
added code.
1 parent 6803d33 commit 813ca56

File tree

4 files changed

+80
-13
lines changed

4 files changed

+80
-13
lines changed

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
},
1010
"dependencies": {
1111
"core-js": "^3.8.3",
12-
"vue": "^3.2.13"
12+
"vue": "^3.2.13",
13+
"vue3-touch-events": "^4.1.0"
1314
},
1415
"devDependencies": {
1516
"@babel/core": "^7.12.16",

src/App.vue

+69-9
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,56 @@
11
<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>
421
</template>
522

623
<script>
7-
import HelloWorld from './components/HelloWorld.vue'
8-
924
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+
};
1554
</script>
1655

1756
<style>
@@ -23,4 +62,25 @@ export default {
2362
color: #2c3e50;
2463
margin-top: 60px;
2564
}
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+
}
2686
</style>

src/main.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { createApp } from 'vue'
2-
import App from './App.vue'
1+
import { createApp } from "vue";
2+
import App from "./App.vue";
3+
import Vue3TouchEvents from "vue3-touch-events";
34

4-
createApp(App).mount('#app')
5+
createApp(App).use(Vue3TouchEvents).mount("#app");

yarn.lock

+5
Original file line numberDiff line numberDiff line change
@@ -5807,6 +5807,11 @@ vue-template-es2015-compiler@^1.9.0:
58075807
resolved "https://registry.npmmirror.com/vue-template-es2015-compiler/-/vue-template-es2015-compiler-1.9.1.tgz#1ee3bc9a16ecbf5118be334bb15f9c46f82f5825"
58085808
integrity sha512-4gDntzrifFnCEvyoO8PqyJDmguXgVPxKiIxrBKjIowvL9l+N66196+72XVYR8BBf1Uv1Fgt3bGevJ+sEmxfZzw==
58095809

5810+
vue3-touch-events@^4.1.0:
5811+
version "4.1.0"
5812+
resolved "https://registry.yarnpkg.com/vue3-touch-events/-/vue3-touch-events-4.1.0.tgz#053500d1e9ab4870efcd5de29530641064d0a7d5"
5813+
integrity sha512-fZKusOiBJzDPsY34tXYl/Wo9c2ONzBuQmF0+oHqVWr+TDbf90CgMWLHZsTv1KaShXjt+oeLow7BDVBpXW6lfXQ==
5814+
58105815
vue@^3.2.13:
58115816
version "3.2.39"
58125817
resolved "https://registry.npmmirror.com/vue/-/vue-3.2.39.tgz#de071c56c4c32c41cbd54e55f11404295c0dd62d"

0 commit comments

Comments
 (0)