Improve menu category selection when scrolling to bottom
Automatically select the last category when the user scrolls to the bottom of the menu list. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -218,8 +218,22 @@ export const Menu = ({
|
|||||||
const menuListScroll = () => {
|
const menuListScroll = () => {
|
||||||
if (isButtonScrolling.current) return;
|
if (isButtonScrolling.current) return;
|
||||||
|
|
||||||
const scrollTop = scrollRef.current?.scrollTop || 0;
|
if (!scrollRef.current) return;
|
||||||
const currentIndex = getCurrentCategoryIndex(scrollTop);
|
|
||||||
|
const scrollTop = scrollRef.current.scrollTop;
|
||||||
|
const scrollHeight = scrollRef.current.scrollHeight;
|
||||||
|
const clientHeight = scrollRef.current.clientHeight;
|
||||||
|
|
||||||
|
// 스크롤이 맨 밑에 도달했는지 확인 (약간의 오차 허용)
|
||||||
|
const isAtBottom = scrollHeight - scrollTop - clientHeight < 1;
|
||||||
|
|
||||||
|
let currentIndex: number;
|
||||||
|
if (isAtBottom) {
|
||||||
|
// 맨 밑이면 마지막 카테고리 선택
|
||||||
|
currentIndex = buttonRefs.current.length - 1;
|
||||||
|
} else {
|
||||||
|
currentIndex = getCurrentCategoryIndex(scrollTop);
|
||||||
|
}
|
||||||
|
|
||||||
if (currentIndex !== shortBtnIdx) {
|
if (currentIndex !== shortBtnIdx) {
|
||||||
setShortBtnIdx(currentIndex);
|
setShortBtnIdx(currentIndex);
|
||||||
|
|||||||
Reference in New Issue
Block a user