Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

캐러셀 슬라이드 구현 (issue#57) #70

Merged
merged 2 commits into from
Jul 19, 2024
Merged

캐러셀 슬라이드 구현 (issue#57) #70

merged 2 commits into from
Jul 19, 2024

Conversation

brgndyy
Copy link
Contributor

@brgndyy brgndyy commented Jul 18, 2024

구현 요약

캐러셀 슬라이드를 구현했습니다.

화면 기록 2024-07-18 오후 9 21 28

연관 이슈

일단 돌아가는 쓰레기 만들어보았습니다..

close #57

@brgndyy brgndyy added 🎨 프론트엔드 프론트엔드 관련 이슈 ⚒️ 기능 작업해야하는 기능 labels Jul 18, 2024
@brgndyy brgndyy added this to the 두번째 스프린트 milestone Jul 18, 2024
@brgndyy brgndyy self-assigned this Jul 18, 2024
Copy link
Contributor

@Parkhanyoung Parkhanyoung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생 많으셨습니다 버건디~!! 코드 넘 잘 짜셨는데요~~~!!!

const carouselItems = React.Children.toArray(children);
const carouselItemLength = carouselItems.length;
const [currentIndex, setCurrentIndex] = useState(1);
const [isAnimating, setIsAnimating] = useState(false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[A]

아주 아주 사소하지만, 찾아보니 Animate의 의미가 '움직이게 만들다'의 느낌이어서 isMoving이나, isSliding 정도로 바꿔보면 어떨까요? 만약 '움직이게 만들다'의 의미를 담고 싶으셨던 거면 유지해도 좋을 것 같습니다 😄

스크린샷 2024-07-19 오후 12 41 02

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

헉 짚어주셔서 감사합니다~!

isSliding으로 바꿔보았어요 !

const useCarousel = ({ children }: PropsWithChildren) => {
const carouselItems = React.Children.toArray(children);
const carouselItemLength = carouselItems.length;
const [currentIndex, setCurrentIndex] = useState(1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

단순 궁금) currentIndex 초기값이 0이 아니라 1인 이유가 궁금해요~~!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

헉 짚어주셔서 감사합니다 :)

(이유 없습니다.. 휴먼 에러.. 🥲)

import type { PropsWithChildren } from 'react';
import React, { useState, useRef, useEffect } from 'react';

const useCarousel = ({ children }: PropsWithChildren) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

버건디 말씀과 다르게 useCarousel 로직 깔끔한데요 ㅎㅎ 뚝딱뚝딱 잘 만드셨네요 👍🏻

Copy link
Contributor

@chosim-dvlpr chosim-dvlpr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

깔끔하게 작성해주셔서 이해가 쏙쏙 되었습니다 ㅎㅎ고생하셨어요~!!

import React, { useState, useRef, useEffect } from 'react';

const useCarousel = ({ children }: PropsWithChildren) => {
const carouselItems = React.Children.toArray(children);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 이런 방법으로도 배열을 만들 수 있군요!! 배워갑니다 👍

Comment on lines +13 to +18
{carouselItems.map((item, index) => (
<S.Slide key={`original-${index}`}>{item}</S.Slide>
))}
{carouselItems.map((item, index) => (
<S.Slide key={`clone-${index}`}>{item}</S.Slide>
))}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

단순 질문) clone 슬라이드는 어떤 역할을 하는지 궁금합니다~! original과 clone 두 개가 있어서요 ㅎㅎ

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

보통 무한 캐러셀을 구현할때 부드러운 애니메이션을 위해서 복제본을 만들더라구요 !

(가령 마지막 슬라이드에서 Next 버튼을 눌렀을때 다시 첫번째 슬라이드로 넘어가는 경우)

스크린샷 2024-07-19 오후 3 05 29

사용하고 있던 기존 캐러셀 라이브러리도 이런식으로 복제본을 만들어서 사용하길래 적용시켜보았습니다!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그렇군요!! 설명 감사합니다 버건디👍

@Parkhanyoung Parkhanyoung merged commit 869351e into main Jul 19, 2024
1 of 2 checks passed
@alstn113 alstn113 deleted the feat/#57 branch July 21, 2024 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚒️ 기능 작업해야하는 기능 🎨 프론트엔드 프론트엔드 관련 이슈
Projects
Status: 😎 DONE
Development

Successfully merging this pull request may close these issues.

캐러셀 슬라이드 구현
3 participants