내배캠 9주차 회고
1) 프로젝트
프로젝트 상세내용은 깃헙 리드미 참고
https://github.com/setItUpLater/comeit
2) 느낀점
프로젝트를 시작할 때 사용할 공통 컴포넌트를 정해서 각자만들고 진행해서 효율적으로 코드를 작성할 수 있어 좋은 경험이였다.
다시한번 기획에 중요성을 느끼고 마감시간을 정해서 지켜야 한다.
멀티플 슬라이드의 자동 이동 기능을 라이브러리 도움 없이 구현하려 했었다.
그러나 들어오는 데이터가 매번 달라지는 이번 프로젝트 특성을 고려하며, 슬라이드를 이동시키는 방법을 찾기 힘들었다.
해결 방안 : 구글링을 통해 싱글 슬라이드의 구현 방법을 알았으니 예시 코드를 찾지 않고 직접 활용해서 처음부터 코드를 작성했다.
const cloneContents = [...contents];
if (auto && overContents) {
for (let i = 0; i < showContentNum; i += 1) {
cloneContents.push(contents[i]);
}
}
const autoplay = ({ duration }) => {
interval = setInterval(autoplayIterator, duration);
};
const autoplayIterator = () => {
setCurrentSlide(prev => {
const newSlide = prev + 1;
slideRef.current.style.transition = "all 0.5s ease-in-out";
slideRef.current.style.transform = `translateX(-${newSlide * (contentWidth + space)}px)`;
if (newSlide > lastSlide) {
clearInterval(interval);
slideRef.current.style.transition = "";
slideRef.current.style.transform = `translateX(-0px)`;
setCurrentSlide(0);
autoplay({ duration: 2000 });
}
return newSlide;
});
};
useMount(() => {
if (type === "intro" && overContents) {
autoplay({ duration: 2000 });
}
});