[상품 디테일] 스크롤 다운 버튼 처리건.

1. documentHeight의 초기값 0으로 변경.
	2. 버튼 눌렀을때 documentHeight 값을 알수없어 이부분 전체 영역 계산으로 변경.
 	3. reviewHeight부분 필요없음으로 인한 제거.
This commit is contained in:
junghoon86.park
2025-09-15 17:22:18 +09:00
parent 9532de2d8b
commit 584d17a784

View File

@@ -164,10 +164,10 @@ export default function ProductAllSection({
const dispatch = useDispatch();
const [currentHeight, setCurrentHeight] = useState(0);
//하단부분까지 갔을때 체크용
const [documentHeight, setDocumentHeight] = useState();
const [documentHeight, setDocumentHeight] = useState(0);
const [isBottom, setIsBottom] = useState(false);
//버튼 active 표시용
const [reviewHeight, setReviewHeight] = useState(0);
const [activeProductBtn, setActiveProductBtn] = useState(false);
const [activeReviewBtn, setActiveReviewBtn] = useState(false);
const [activeYouMayLikeBtn, setActiveYouMayLikeBtn] = useState(false);
@@ -337,15 +337,20 @@ export default function ProductAllSection({
const handleArrowClickAlternative = useCallback(() => {
const currentHeight = scrollPositionRef.current;
const scrollAmount = 200;
scrollTop({
y: currentHeight + scrollAmount,
animate: true,
});
if (documentHeight) {
const isAtBottom = scrollPositionRef.current + 944 >= documentHeight;
if (isAtBottom !== isBottom) {
setIsBottom(isAtBottom);
}
const isAtBottom =
scrollPositionRef.current + 1100 >=
(productDetailRef.current?.scrollHeight || 0) +
(descriptionRef.current?.scrollHeight || 0) +
(reviewRef.current?.scrollHeight || 0) +
(youMayAlsoLikelRef.current?.scrollHeight || 0);
if (isAtBottom) {
setIsBottom(isAtBottom);
}
}, []);
@@ -394,11 +399,6 @@ export default function ProductAllSection({
(descriptionRef.current?.scrollHeight || 0) +
(reviewRef.current?.scrollHeight || 0)
);
setReviewHeight(
(productDetailRef.current?.scrollHeight || 0) +
(descriptionRef.current?.scrollHeight || 0) +
(reviewRef.current?.scrollHeight || 0)
);
}, [
productDetailRef.current,
descriptionRef.current,