-
Notifications
You must be signed in to change notification settings - Fork 4
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
JavaScript로 제어하는 스크롤 스냅 구현 #459
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.
확인 부탁드립니다 ❤️
}; | ||
|
||
const CafeCard = (props: CardProps) => { | ||
const { cafe, onIntersect } = props; |
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.
오 Intersection도 필요가 없나보네
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.
그럼요~~ DOM의 제어로 인해 발생하는 이벤트를 구독할 필요가 없습니다
overflow-y: hidden; | ||
`; | ||
|
||
export default ScrollSnapContainer; |
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.
오호... ScrollSnapContainer
여기가 핵심이군여
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.
맞습니다!!
|
||
return ( | ||
<Container | ||
{...divProps} |
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.
여기는 어떤 것이 들어올 것을 예상하고 추가를 하셨나요?
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.
<div>
에서 원래 사용하는 props를 그대로 포워딩해준 것입니다!
onMouseMove={handleMouseMove} | ||
onMouseUp={handleMouseUp} | ||
onMouseLeave={handleMouseLeave} | ||
onWheel={handleWheel} |
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.
handleWheel
은 무슨 기능인가요?
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.
마우스 휠을 조작하면 발생하는 이벤트입니다
export const easeOutExpo = (x: number): number => { | ||
return x === 1 ? 1 : 1 - Math.pow(2, -10 * x); | ||
}; |
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.
이 친구는 어떤 역할을 하나요?
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.
각각의 값들이 무엇을 의미하는지 알 수가 없어서, 더 해석이 힘든 것 같아요!
값들에 적절한 네이밍을 붙여주는 건 어떨까요?
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.
스니펫이라 그런데 양해 부탁드립니다 😭 이름을 붙이기 보다 easeOutExpo
그 자체로 이해하고 사용하는 것이 좋을 것 같습니다
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.
고생하셨습니다🚀
Approve 하겠습니다
// 터치 방향(좌우 혹은 상하)에 따라 스와이프를 해야할 지 결정하는 상태 | ||
// 이 상태에선 실질적으로 스와이프가 동작하지 않는다 | ||
| { |
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.
여쭤볼 게 있습니다!
프론트엔드에서는 코드에 주석을 많이 쓰는 편인가요??
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.
원래 잘 쓰진 않으나 이 파일에선 핵심적이고 복잡한 로직을 설명하는 것이 중요하기 때문에 의도적으로 주석을 많이 채웠습니다
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.
어렵네요 리액트 ㅠㅠ
export const easeOutExpo = (x: number): number => { | ||
return x === 1 ? 1 : 1 - Math.pow(2, -10 * x); | ||
}; |
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.
각각의 값들이 무엇을 의미하는지 알 수가 없어서, 더 해석이 힘든 것 같아요!
값들에 적절한 네이밍을 붙여주는 건 어떨까요?
백엔드 아저씨들도 리뷰해주시는군요 ㅋㅋㅋ 감사합니당 |
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.
굿굿 확인하였습니다!
#️⃣ 연관된 이슈
close #51
close #294
close #302
📝 작업 내용
touchmove
이벤트와transition: translateY(*px)
의 조합으로 스크롤을 제어합니다.🐼 구현 내용
ScrollSnapContainer
컴포넌트에 구현되어 있습니다.ScrollSnapContainer
는 위의 상태 중 하나만 가질 수 있습니다.FSM 상태는 tagged union으로 나타내었으며 상태의 전이는
setState
를 통해 할 수 있습니다.'touchmove'
상태로 전이하는 예시는 위와 같습니다.전체 아이템 갯수와 상관없이 위, 아래 아이템까지만 렌더링하기 때문에 성능에도 긍정적인 영향을 줍니다.
🥹 향후 구현 필요한 내용
💬 리뷰 요구사항