Skip to content

Commit 4f8e5f5

Browse files
committed
Add opacity to back side
1 parent 98ae842 commit 4f8e5f5

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

examples/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from "react"
22
import { View, StyleSheet, Button } from "react-native"
33

4-
import FlipCard from "../index"
4+
import FlipCard from "../src/index"
55
import Side from "./Side"
66

77
const App = () => {

examples/babel.config.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,5 @@ module.exports = function(api) {
22
api.cache(true)
33
return {
44
presets: ["babel-preset-expo"],
5-
plugins: [
6-
[
7-
"module-resolver",
8-
{
9-
alias: {
10-
"react-native-flip": "../index",
11-
},
12-
},
13-
],
14-
],
155
}
166
}

src/index.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from "react"
22
import { StyleSheet } from "react-native"
33
import Animated from "react-native-reanimated"
4-
import { bInterpolate, spring } from "react-native-redash"
4+
import { spring } from "react-native-redash"
55

66
const {
77
Value,
@@ -44,22 +44,32 @@ const ReanimatedFlip = ({ perspective = 350, side, front, back }: Props) => {
4444
[side]
4545
)
4646

47-
const rotateY = concat(bInterpolate(flipPosition, 0, 180), "deg")
47+
const rotatePosition = interpolate(flipPosition, {
48+
inputRange: [0, 1],
49+
outputRange: [0, 180],
50+
})
51+
const rotateY = concat(rotatePosition, "deg")
4852

49-
const opacity = interpolate(flipPosition, {
53+
const opacityFront = interpolate(flipPosition, {
5054
inputRange: [0.5, 0.51],
5155
outputRange: [1, 0],
5256
extrapolate: Animated.Extrapolate.CLAMP,
5357
})
5458

59+
const opacityBack = interpolate(flipPosition, {
60+
inputRange: [0.5, 0.51],
61+
outputRange: [0, 1],
62+
extrapolate: Animated.Extrapolate.CLAMP,
63+
})
64+
5565
return (
5666
<Animated.View style={styles.container}>
5767
<Animated.View
5868
style={[
5969
styles.side,
6070
styles.front,
6171
{
62-
opacity,
72+
opacity: opacityFront,
6373
transform: [{ perspective }, { rotateY }],
6474
},
6575
]}
@@ -71,6 +81,7 @@ const ReanimatedFlip = ({ perspective = 350, side, front, back }: Props) => {
7181
styles.side,
7282
styles.back,
7383
{
84+
opacity: opacityBack,
7485
transform: [{ perspective }, { rotateY: "180deg" }, { rotateY }],
7586
},
7687
]}

0 commit comments

Comments
 (0)