-
Notifications
You must be signed in to change notification settings - Fork 0
/
TapHandler.js
80 lines (76 loc) · 1.78 KB
/
TapHandler.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import { StatusBar } from "expo-status-bar";
import { useEffect, useRef } from "react";
import {
StyleSheet,
Text,
View,
Image,
Dimensions,
ImageBackground,
} from "react-native";
import {
TapGestureHandler,
Gesture,
GestureDetector,
GestureHandlerRootView,
} from "react-native-gesture-handler";
import Animated, {
useSharedValue,
useAnimatedStyle,
withTiming,
withSpring,
withRepeat,
} from "react-native-reanimated";
export default function App() {
const singleTap = Gesture.Tap().onEnd((_event, success) => {
if (success) {
console.log("single tap!");
}
});
const doubleTap = Gesture.Tap()
.numberOfTaps(2)
.onEnd((_event, success) => {
if (success) {
console.log("double tap!");
}
});
const taps = Gesture.Exclusive(doubleTap, singleTap);
return (
<GestureHandlerRootView style={styles.container}>
<GestureDetector gesture={taps}>
<Animated.View>
<ImageBackground
source={require("./assets/image.jpg")}
style={styles.image}
>
<Image
source={require("./assets/heart.png")}
style={[
styles.image,
{
shadowOffset: { width: 0, height: 20 },
shadowOpacity: 0.35,
shadowRadius: 35,
},
]}
resizeMode={"center"}
/>
</ImageBackground>
</Animated.View>
</GestureDetector>
</GestureHandlerRootView>
);
}
const { width: SIZE } = Dimensions.get("window");
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center",
},
image: {
width: SIZE,
height: SIZE,
},
});