Skip to content

Commit c0916a3

Browse files
committed
Make images cross-fade smoothly
1 parent 43ebc36 commit c0916a3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

website/src/components/StickyGrid/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { ComponentProps, useRef } from "react";
1+
import React, { ComponentProps, useId, useRef } from "react";
22
import {
33
AnimatePresence,
44
motion,
@@ -33,6 +33,7 @@ export const StickyGrid = ({ cards }: Props) => {
3333
);
3434
setActiveCard(closestBreakpointIndex);
3535
});
36+
const id = useId();
3637

3738
return (
3839
<div className="w-full flex flex-row gap-20" ref={ref}>
@@ -50,11 +51,13 @@ export const StickyGrid = ({ cards }: Props) => {
5051
))}
5152
</div>
5253
<div className="sticky top-24 right-0 hidden aspect-[3/2] h-full w-1/2 overflow-hidden rounded-md md:block">
53-
<AnimatePresence initial={false}>
54+
<AnimatePresence mode="popLayout">
5455
<motion.div
5556
key={activeCardIndex}
5657
initial={{ opacity: 0 }}
5758
animate={{ opacity: 1 }}
59+
exit={{ opacity: 0 }}
60+
transition={{ duration: 0.5 }}
5861
>
5962
{cards[activeCardIndex].image}
6063
</motion.div>

0 commit comments

Comments
 (0)