@@ -92,17 +92,6 @@ export default function CardCollapse(props: CardCollapseProps) {
9292 LayoutAnimation . configureNext ( LayoutAnimation . Presets . easeInEaseOut ) ;
9393 } , [ collapsed ] ) ;
9494
95- function getItemScale ( index : number ) {
96- if ( collapsed ) {
97- if ( index === itemsCount - 2 ) {
98- return 0.95 ;
99- }
100- if ( index === itemsCount - 1 ) {
101- return 0.9 ;
102- }
103- }
104- return 1 ;
105- }
10695 // 动画
10796 const animate = async ( ) => {
10897 return Promise . all ( [ animateValues ( ) , animateCards ( ) ] ) ;
@@ -133,6 +122,13 @@ export default function CardCollapse(props: CardCollapseProps) {
133122 } ) ;
134123 } ;
135124
125+ function getItemScale ( index : number ) {
126+ if ( collapsed ) {
127+ return 0.9 ;
128+ }
129+ return 1 ;
130+ }
131+
136132 const animateCards = ( ) => {
137133 const promises = [ ] ;
138134 for ( let index = 0 ; index < itemsCount ; index ++ ) {
@@ -210,21 +206,23 @@ export default function CardCollapse(props: CardCollapseProps) {
210206
211207 const renderItem = ( item : JSX . Element | JSX . Element [ ] , index : number ) => {
212208 return (
213- < Animated . View
209+ < Animated . View
214210 key = { index }
215- onLayout = { index === 0 ? onLayout : undefined }
216- style = { [
217- Platform . OS === 'ios' && styles . containerShadow ,
218- getStyle ( index ) ,
219- {
220- borderRadius : Platform . OS === 'ios' ? itemBorderRadius : undefined ,
221- alignSelf : 'center' ,
222- zIndex : itemsCount - index ,
223- transform : [ { scaleX : animatedScaleArray [ index ] } ] ,
224- width : Dimensions . get ( 'screen' ) . width - 40 ,
225- height : collapsed ? firstItemHeight : undefined ,
226- } ,
227- ] }
211+ onLayout = { index === 0 ? onLayout : undefined
212+ }
213+ style = {
214+ [
215+ Platform . OS === 'ios' && styles . containerShadow ,
216+ getStyle ( index ) ,
217+ {
218+ borderRadius : Platform . OS === 'ios' ? itemBorderRadius : undefined ,
219+ alignSelf : 'center' ,
220+ zIndex : itemsCount - index ,
221+ transform : [ { scaleX : animatedScaleArray [ index ] } ] ,
222+ width : Dimensions . get ( 'screen' ) . width - 40 ,
223+ height : collapsed ? firstItemHeight : undefined ,
224+ } ,
225+ ] }
228226 collapsable = { false }
229227 >
230228 < Container
@@ -237,7 +235,7 @@ export default function CardCollapse(props: CardCollapseProps) {
237235 </ Animated . View >
238236 </ TouchableOpacity >
239237 </ Container >
240- </ Animated . View >
238+ </ Animated . View >
241239 ) ;
242240 } ;
243241 return (
0 commit comments