-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat: useDragIndexCarousel Infinity mode추가, useInterval 훅 추가 #3
feat: useDragIndexCarousel Infinity mode추가, useInterval 훅 추가 #3
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수고하셨습니다!
ref.current!.style.transition = 'none'; | ||
ref.current!.style.transform = `translateX(${-getSliderWidth()}px)`; | ||
setIndex(1); | ||
ref.current!.removeEventListener('transitionend', resetToFirstPage); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ref.current
가 있는지 이미 검사하고 있기 때문에 assertion을 사용하지 않아도 될 것 같아요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
반영하였습니다!
@@ -133,7 +183,7 @@ export default function useDragIndexCarousel( | |||
prev, | |||
isEnd, | |||
isStart, | |||
} = _useDragIndexCarousel(dataLength - 1, minMove, startIndex); | |||
} = _useDragIndexCarousel(realDataLength, minMove, startIndex, infinity); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_useDragIndexCarousel
를 사용했다면 handleTouchStart
과 같은 이벤트 핸들러들의 타입 추론이 되지 않나요??
190번째 줄부터 as any
가 꼭 필요할까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이벤트 타입 때문에 이런 문제가 발생했네요!
React.TouchEvent가 아니라 TouchEvent로 변경하여 any제거하였습니다!
} from 'react'; | ||
import { useRef, useState, Children, ReactNode } from 'react'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
react
가 중복 import 되어있네요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
반영하였습니다!
infinity mode추가
drag Carousel 에 infinity mode를 추가하였습니다.
2024-05-10.13-07-18.mp4
요소 앞뒤로 최후방요소와 최상단 요소를 복사하여 각각 추가하고, index를 translate계산할때에 적용하여 자연스럽게 보일 수 있도록 처리했습니다.
최후방요소에 도달한 경우
useInterval 추가
setInterval을 컴포넌트 내부에서 멈췄다 다시 진행시켰다 하는 부분이 내부 렌더링 로직에 의해 의도대로 동작하지 않는 문제를 해결하기 위한 훅인 useInterval 기능을 추가하였습니다.