Skip to content

Commit

Permalink
Fix: 속성선택 아코디언을 닫을 때, 애니메이션이 동작하지 않는 오류 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
cdm1263 committed Feb 23, 2024
1 parent 303279b commit 1cd1571
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/components/plate/FilterPlates.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ import useSelectedStore from '@/store/useSelectedStore';
import PlateHideButton from './PlateHideButton';
import { useState } from 'react';
import { AnimatePresence, motion } from 'framer-motion';
import useCalculateInnerWidth from '@/hook/useCalculateInnerWidth';

const FilterPlates = () => {
const koreanTypes = Object.values(POKEMON_TYPES);
const [isOpen, setIsOpen] = useState<boolean>(false);
const { selectedPlate, setSelectedPlate } = useSelectedStore();
const innerWidth = useCalculateInnerWidth();

const variants = {
open: { height: '200px' },
closed: { height: 0 },
open: { height: '200px', opacity: 1 },
closed: { height: 0, opacity: 0 },
};

const renderTypes = (types: string[]) =>
Expand Down Expand Up @@ -44,13 +46,12 @@ const FilterPlates = () => {
return (
<div className={styles.wrapper}>
<AnimatePresence>
{isOpen ? (
{isOpen && (
<motion.div
initial="closed"
animate="open"
exit="closed"
variants={variants}
transition={{ duration: 0.3 }}
variants={innerWidth <= 768 ? {} : variants}
className={styles.container}
>
<div className={styles.inner}>
Expand All @@ -62,8 +63,6 @@ const FilterPlates = () => {
</motion.div>
</div>
</motion.div>
) : (
<div></div>
)}
</AnimatePresence>
<PlateHideButton isOpen={isOpen} setIsOpen={setIsOpen} />
Expand Down

0 comments on commit 1cd1571

Please sign in to comment.