11import React from "react" ;
2+ import { StyleSheet } from "react-native" ;
23import Animated , {
34 interpolate ,
45 interpolateNode ,
56 multiply ,
67} from "react-native-reanimated" ;
8+ import { useDraggableFlatListContext } from "../context/draggableFlatListContext" ;
79import { useNode } from "../hooks/useNode" ;
810export { useOnCellActiveAnimation } from "../hooks/useOnCellActiveAnimation" ;
911import { useOnCellActiveAnimation } from "../hooks/useOnCellActiveAnimation" ;
@@ -30,10 +32,14 @@ export const ScaleDecorator = ({ activeScale = 1.1, children }: ScaleProps) => {
3032 } )
3133 ) ;
3234
35+ const { horizontal } = useDraggableFlatListContext < any > ( ) ;
3336 const scale = isActive ? animScale : 1 ;
3437 return (
3538 < Animated . View
36- style = { { transform : [ { scaleX : scale } , { scaleY : scale } ] } }
39+ style = { [
40+ { transform : [ { scaleX : scale } , { scaleY : scale } ] } ,
41+ horizontal && styles . horizontal ,
42+ ] }
3743 >
3844 { children }
3945 </ Animated . View >
@@ -56,6 +62,8 @@ export const ShadowDecorator = ({
5662 children,
5763} : ShadowProps ) => {
5864 const { isActive, onActiveAnim } = useOnCellActiveAnimation ( ) ;
65+ const { horizontal } = useDraggableFlatListContext < any > ( ) ;
66+
5967 const shadowOpacity = useNode ( multiply ( onActiveAnim , opacity ) ) ;
6068
6169 const style = {
@@ -65,7 +73,11 @@ export const ShadowDecorator = ({
6573 shadowOpacity : isActive ? shadowOpacity : 0 ,
6674 } ;
6775
68- return < Animated . View style = { style } > { children } </ Animated . View > ;
76+ return (
77+ < Animated . View style = { [ style , horizontal && styles . horizontal ] } >
78+ { children }
79+ </ Animated . View >
80+ ) ;
6981} ;
7082
7183type OpacityProps = {
@@ -78,6 +90,8 @@ export const OpacityDecorator = ({
7890 children,
7991} : OpacityProps ) => {
8092 const { isActive, onActiveAnim } = useOnCellActiveAnimation ( ) ;
93+ const { horizontal } = useDraggableFlatListContext < any > ( ) ;
94+
8195 const opacity = useNode (
8296 interpolateFn ( onActiveAnim , {
8397 inputRange : [ 0 , 1 ] ,
@@ -89,5 +103,16 @@ export const OpacityDecorator = ({
89103 opacity : isActive ? opacity : 1 ,
90104 } ;
91105
92- return < Animated . View style = { style } > { children } </ Animated . View > ;
106+ return (
107+ < Animated . View style = { [ style , horizontal && styles . horizontal ] } >
108+ { children }
109+ </ Animated . View >
110+ ) ;
93111} ;
112+
113+ const styles = StyleSheet . create ( {
114+ horizontal : {
115+ flexDirection : "row" ,
116+ flex : 1 ,
117+ } ,
118+ } ) ;
0 commit comments