@@ -33,42 +33,54 @@ const SnippetList = () => {
33
33
return (
34
34
< >
35
35
< motion . ul role = "list" className = "snippets" >
36
- < AnimatePresence mode = "popLayout" >
37
- { fetchedSnippets . map ( ( snippet , idx ) => (
38
- < motion . li
39
- key = { idx }
40
- initial = { { opacity : 0 , y : 20 } }
41
- animate = { {
42
- opacity : 1 ,
43
- y : 0 ,
44
- transition : {
45
- delay : idx * 0.05 ,
46
- duration : 0.2 ,
47
- } ,
48
- } }
49
- exit = { {
50
- opacity : 0 ,
51
- y : - 20 ,
52
- transition : {
53
- delay : ( fetchedSnippets . length - 1 - idx ) * 0.01 ,
54
- duration : 0.09 ,
55
- } ,
56
- } }
57
- >
58
- < motion . button
59
- className = "snippet | flow"
60
- data-flow-space = "sm"
61
- onClick = { ( ) => handleOpenModal ( snippet ) }
62
- whileHover = { { scale : 1.01 } }
63
- whileTap = { { scale : 0.98 } }
36
+ < AnimatePresence mode = "popLayout" presenceAffectsLayout >
37
+ { fetchedSnippets . map ( ( currentSnippet , idx ) => {
38
+ return (
39
+ < motion . li
40
+ key = { currentSnippet . title + idx }
41
+ initial = { { opacity : 0 , y : 20 } }
42
+ layoutId = { currentSnippet . title + ( idx + 1 ) . toString ( ) }
43
+ animate = { {
44
+ opacity : 1 ,
45
+ y : 0 ,
46
+ transition : {
47
+ delay : 0.09 + idx * 0.05 ,
48
+ duration : 0.2 ,
49
+ } ,
50
+ } }
51
+ exit = { {
52
+ opacity : 0 ,
53
+ y : - 20 ,
54
+ transition : {
55
+ delay : idx * 0.01 ,
56
+ duration : 0.09 ,
57
+ } ,
58
+ } }
59
+ transition = { {
60
+ type : "spring" ,
61
+ duration : 0.5 ,
62
+ } }
64
63
>
65
- < div className = "snippet__preview" >
66
- < img src = { language . icon } alt = { language . lang } />
67
- </ div >
68
- < h3 className = "snippet__title" > { snippet . title } </ h3 >
69
- </ motion . button >
70
- </ motion . li >
71
- ) ) }
64
+ < motion . button
65
+ className = "snippet | flow"
66
+ data-flow-space = "sm"
67
+ onClick = { ( ) =>
68
+ handleOpenModal ( {
69
+ ...currentSnippet ,
70
+ idx : idx + 1 ,
71
+ } )
72
+ }
73
+ whileHover = { { scale : 1.01 } }
74
+ whileTap = { { scale : 0.98 } }
75
+ >
76
+ < div className = "snippet__preview" >
77
+ < img src = { language . icon } alt = { language . lang } />
78
+ </ div >
79
+ < h3 className = "snippet__title" > { currentSnippet . title } </ h3 >
80
+ </ motion . button >
81
+ </ motion . li >
82
+ ) ;
83
+ } ) }
72
84
</ AnimatePresence >
73
85
</ motion . ul >
74
86
0 commit comments