Skip to content

Conversation

@orrhrr
Copy link
Contributor

@orrhrr orrhrr commented Apr 12, 2024

구현사항

  • 모바일버전에서 드래그 하면 이미지가 넘어가도록 수정
  • 무한루프로 이미지 변경되도록 수정
  • 마우스오버 스타일 삭제
    개발자도구에서 클릭한 버튼 스타일이 유지되던 이유가 마우스오버 스타일 때문이였더라구요..
    모바일에서도 hover 이벤트와 touch 이벤트가 잘 구분되지 않아서 가끔 눌린채로 유지되는것처럼 보이는걸로 추정합니다.
    그래서 그냥 지워버렸긔

사용방법

코멘트 참고해주세용

스크린샷

2024-04-04.6.06.40.mov
close

@orrhrr orrhrr added feat 기능구현 refactor 코드 개선 labels Apr 12, 2024
@orrhrr orrhrr added this to the 리팩토링 milestone Apr 12, 2024
@orrhrr orrhrr self-assigned this Apr 12, 2024
@orrhrr orrhrr requested a review from a team as a code owner April 12, 2024 09:03
@vercel
Copy link

vercel bot commented Apr 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
front-bookstore-readme ✅ Ready (Inspect) Visit Preview Apr 12, 2024 9:03am

<div className="flex-center left-30% absolute bottom-20 z-10 h-20 w-100 gap-10 mobile:bottom-8">
{currList.map((_, idx) => (
<button
className={`h-10 w-10 rounded-full bg-gray-1 hover:bg-primary active:bg-primary ${ButtonActiveIndex === idx ? 'bg-primary' : ''} mobile:h-5 mobile:w-5`}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

이놈때문에 버그인줄알고 삽질 너무많이했네요 흑

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 +130 to +132
onTouchStart={handleTouchStart}
onTouchMove={handleTouchMove}
onTouchEnd={handleTouchEnd}>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

onTouchStart, onTouchMove, onTouchEnd 라는 이벤트가 따로 있더라구요.
터치가 가능한 기기(모바일,테블릿 등)에서만 발생되는 이벤트라고 합니다.
그래서 써봤어용!

  • 사용자가 터치가능한 기기에서만 작동하는 touch Event(모바일, 테블릿 등..)
    • onTouchStart, onTouchMove, onTouchEnd, onTouchCancel
      • [touchstart] 이벤트 - 사용자가 화면에 손가락을 대면 발생.
      • [touchmove] 이벤트 - touchstart 이벤트 후, 손가락을 이동시켰을 때 발생. / 이벤트 핸들러를 등록하여 사용자가 터치 이벤트를 발생시키는 지점을 추적하거나, 드래그 앤 드롭 작업을 구현하는 데 사용됨.
      • [touchend] 이벤트: 사용자가 손가락을 화면에서 떼면 발생. / 이벤트 핸들러를 등록하여 사용자의 터치 이벤트를 감지하고, 해당 이벤트에 대한 처리를 수행하는 데 사용됨.
      • [touchcancel] 이벤트: touchstart 이벤트가 발생한 후, touchmove 이벤트가 발생하지 않고 touchend 이벤트도 발생하지 않는 경우, 이벤트 핸들러를 등록하여 touch 이벤트를 취소하고, 해당 이벤트에 대한 처리를 수행하는 데 사용됨.

Copy link
Contributor

Choose a reason for hiding this comment

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

너무 정성스러운 설명 감사해요! 덕분에 저도 onTouchStart, onTouchMove, onTouchEnd 이벤트를 첨 알게 됐네요!!

Copy link
Contributor

Choose a reason for hiding this comment

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

저두 완전 감동입니다...


// 터치 이벤트 함수
const handleTouchStart = (e: React.TouchEvent<HTMLUListElement>) => {
touchStartRef.current = e.touches[0].clientX;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

터치가 시작되면 해당 좌표를 받습니다.

touchStartRef.current = e.touches[0].clientX;
};

const handleTouchMove = (e: React.TouchEvent<HTMLUListElement>) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

터치하고 움직인 거리의 좌표를 받습니다.

Comment on lines +48 to +60
const diff = touchStartRef.current - touchEndRef.current;
const sensitivity = 50; // 터치 이벤트 감지 감도 (좌우 이동 거리)
if (diff > sensitivity) {
// 오른쪽으로 슬라이드
const newIndex = currIndex === currList.length ? 1 : currIndex + 1;
setCurrIndex(newIndex);
setButtonActiveIndex(newIndex - 1);
} else if (diff < -sensitivity) {
// 왼쪽으로 슬라이드
const newIndex = currIndex === 1 ? currList.length : currIndex - 1;
setCurrIndex(newIndex);
setButtonActiveIndex(newIndex - 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.

터치 이벤트 감지 감도를 비교하여, 해당 감도(50)이상 만큼 이동이 있을 경우,
오른쪽인지 왼쪽인지를 감지하여 이전 이미지, 혹은 다음이미지를 보여줍니다.

@thisisthewa2
Copy link
Contributor

어푸!! 🏊‍♂️

Copy link
Contributor

@hyejungan hyejungan left a comment

Choose a reason for hiding this comment

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

그녀의 멋집에 눈물 콸콸!!
저두 이제부터 좀 열심히 살아보겠습니닿ㅎㅎㅎ

<div className="flex-center left-30% absolute bottom-20 z-10 h-20 w-100 gap-10 mobile:bottom-8">
{currList.map((_, idx) => (
<button
className={`h-10 w-10 rounded-full bg-gray-1 hover:bg-primary active:bg-primary ${ButtonActiveIndex === idx ? 'bg-primary' : ''} mobile:h-5 mobile:w-5`}
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 +130 to +132
onTouchStart={handleTouchStart}
onTouchMove={handleTouchMove}
onTouchEnd={handleTouchEnd}>
Copy link
Contributor

Choose a reason for hiding this comment

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

저두 완전 감동입니다...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat 기능구현 refactor 코드 개선

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants