File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -303,33 +303,42 @@ const App: React.FC = () => {
303303 { /* Animated tiles */ }
304304 < div className = "absolute inset-4 pointer-events-none" >
305305 < AnimatePresence >
306- { tiles . map ( ( tile ) => (
307- < motion . div
308- key = { tile . id }
309- layout
310- initial = { tile . isNew ? { scale : 0 , opacity : 0 } : false }
311- animate = { {
312- scale : 1 ,
313- opacity : 1 ,
314- x : `calc(${ tile . col * 100 } % + ${ tile . col * 16 } px)` ,
315- y : `calc(${ tile . row * 100 } % + ${ tile . row * 16 } px)` ,
316- } }
317- exit = { { scale : 0 , opacity : 0 } }
318- transition = { {
319- type : "spring" ,
320- stiffness : 300 ,
321- damping : 30 ,
322- duration : 0.15
323- } }
324- className = { `absolute flex items-center justify-center text-3xl font-bold rounded-md ${ getTileColor ( tile . value ) } ` }
325- style = { {
326- width : 'calc(25% - 12px)' ,
327- height : 'calc(25% - 12px)' ,
328- } }
329- >
330- { tile . value }
331- </ motion . div >
332- ) ) }
306+ { tiles . map ( ( tile ) => {
307+ const tileSize = `calc(25% - 12px)` ;
308+ const xPos = `calc(${ tile . col * 25 } % + ${ tile . col * 16 } px)` ;
309+ const yPos = `calc(${ tile . row * 25 } % + ${ tile . row * 16 } px)` ;
310+
311+ return (
312+ < motion . div
313+ key = { tile . id }
314+ initial = { tile . isNew ? {
315+ scale : 0 ,
316+ opacity : 0 ,
317+ left : xPos ,
318+ top : yPos ,
319+ } : false }
320+ animate = { {
321+ scale : 1 ,
322+ opacity : 1 ,
323+ left : xPos ,
324+ top : yPos ,
325+ } }
326+ exit = { { scale : 0 , opacity : 0 } }
327+ transition = { {
328+ type : "spring" ,
329+ stiffness : 260 ,
330+ damping : 26 ,
331+ } }
332+ className = { `absolute flex items-center justify-center text-3xl font-bold rounded-md ${ getTileColor ( tile . value ) } ` }
333+ style = { {
334+ width : tileSize ,
335+ height : tileSize ,
336+ } }
337+ >
338+ { tile . value }
339+ </ motion . div >
340+ ) ;
341+ } ) }
333342 </ AnimatePresence >
334343 </ div >
335344
You can’t perform that action at this time.
0 commit comments