diff --git a/com.twin.app.shoptime/src/views/HotPicksPanel/HotPicksPanel.jsx b/com.twin.app.shoptime/src/views/HotPicksPanel/HotPicksPanel.jsx index f87b6fc4..dd2a468b 100644 --- a/com.twin.app.shoptime/src/views/HotPicksPanel/HotPicksPanel.jsx +++ b/com.twin.app.shoptime/src/views/HotPicksPanel/HotPicksPanel.jsx @@ -54,38 +54,59 @@ const Container = SpotlightContainerDecorator( export default function HotPicksPanel({ panelInfo }) { const { sendLogCuration, sendLogGNB, sendLogShopByMobile } = useLogService(); - const dispatch = useDispatch(); + const scrollJob = useRef(new Job((func) => func(), 100)); const spotJob = useRef(new Job((func) => func(), 200)); + const { cursorVisible } = useSelector((state) => state.common.appStatus); + const themeCurationInfoData = useSelector( (state) => state.home?.themeCurationInfoData?.themeInfos ); + const themeCurationInfoDataRef = usePrevious(themeCurationInfoData); + const { popupVisible, activePopup } = useSelector( (state) => state.common.popup ); + const userNumber = useSelector( (state) => state.common?.appStatus.loginUserData.userNumber ); - const [movingPage, setMovingPage] = useState(false); const [currentPage, setCurrentPage] = useState( panelInfo.currentPage ? panelInfo.currentPage : 0 ); + + const smsRetCode = useSelector((state) => state.appData.sendSms?.retCode); + const currentPageRef = usePrevious(currentPage); + const [oneLog, setOneLog] = useState(false); - const [oneSpot, setOneSpot] = useState(false); const [popPatnrId, setPopPatnrId] = useState(null); const [popCurationId, setPopCurationId] = useState(null); const [popEvntId, setPopEvntId] = useState(null); const [popEventInfo, setPopEventInfo] = useState(null); const [isCurationEvnt, setIsCurationEvnt] = useState(null); - const smsRetCode = useSelector((state) => state.appData.sendSms?.retCode); + const [components, setComponents] = useState([]); + + const spotYoffsetRef = useRef(0); + let spotlightId = null; - const [components, setComponents] = useState([]); + const _onScrollStop = (e) => { + spotYoffsetRef.current = e.scrollTop; + const targetY = currentPageRef.current * window.innerHeight; + if (targetY !== e.scrollTop) { + scrollJob.current.startAfter(0, () => { + scrollToRef.current({ + position: { y: currentPage * window.innerHeight }, + animate: false, + }); + }); + } + }; const logParamsRef = useRef(null); @@ -100,6 +121,7 @@ export default function HotPicksPanel({ panelInfo }) { ) => { let itemData = []; itemData.push(JSON.parse(JSON.stringify(data))); + let Component = null; switch (templateCode) { @@ -275,23 +297,21 @@ export default function HotPicksPanel({ panelInfo }) { sendLogCuration, ]); - const onItemSpotlightDown = useCallback(() => { - if (!movingPage) { - setMovingPage(true); - + const onItemSpotlightDown = useCallback((ev) => { + ev.stopPropagation(); + ev.preventDefault(); + if (currentPageRef.current < themeCurationInfoDataRef.current?.length - 1) { Spotlight.focus("hotpicks-next-arrow"); - setMovingPage(false); } - }, [movingPage]); - - const onItemSpotlightUp = useCallback(() => { - if (!movingPage) { - setMovingPage(true); + }, []); + const onItemSpotlightUp = useCallback((ev) => { + ev.stopPropagation(); + ev.preventDefault(); + if (currentPageRef.current > 0) { Spotlight.focus("hotpicks-prev-arrow"); - setMovingPage(false); } - }, [movingPage]); + }, []); const handlePop = useCallback(() => { dispatch(setHidePopup()); @@ -375,20 +395,35 @@ export default function HotPicksPanel({ panelInfo }) { useEffect(() => { const scrollJobValue = scrollJob.current; + const spotJobValue = spotJob.current; if (typeof window === "object" && scrollToRef.current) { + spotJobValue.stop(); scrollJobValue.start(() => { scrollToRef.current({ position: { y: currentPage * window.innerHeight }, animate: false, }); - if (panelInfo.currentSpot && !oneSpot) { - Spotlight.focus(panelInfo.currentSpot); - setOneSpot(true); + if (panelInfo?.currentSpot) { + spotJobValue.start(() => { + Spotlight.focus(panelInfo?.currentSpot); + }); + dispatch( + updatePanel({ + name: panel_names.HOT_PICKS_PANEL, + panelInfo: { + currentSpot: "", + }, + }) + ); + } else { + spotJobValue.start(() => { + Spotlight.focus("hotpicks-data-spot" + (currentPage * 1 + 1)); + }); } }); } - }, [currentPage, oneSpot, panelInfo.currentSpot, scrollToRef]); + }, [currentPage]); const handleWheel = (e) => { let deltaY = e.deltaY; @@ -420,30 +455,7 @@ export default function HotPicksPanel({ panelInfo }) { }) ); }; - }, [currentPageRef, dispatch, panelInfo.currentPage]); - useEffect(() => { - const spotJobValue = spotJob.current; - if (panelInfo?.currentSpot) { - spotJobValue.start(() => { - Spotlight.focus(panelInfo?.currentSpot); - }); - dispatch( - updatePanel({ - name: panel_names.HOT_PICKS_PANEL, - panelInfo: { - currentSpot: "", - }, - }) - ); - } else { - spotJobValue.start(() => { - Spotlight.focus("hotpicks-data-spot" + (currentPage * 1 + 1)); - }); - } - return () => { - spotJobValue.stop(); - }; - }, [currentPage]); + }, [dispatch, panelInfo.currentPage]); useEffect(() => { if (!popupVisible) { @@ -538,20 +550,14 @@ export default function HotPicksPanel({ panelInfo }) { }, [smsRetCode]); const onSpotlightUp = (ev) => { - if (Spotlight.focus()) { - ev.stopPropagation(); - ev.preventDefault(); - - handlePrev(); - } + ev.stopPropagation(); + ev.preventDefault(); + handlePrev(); }; const onSpotlightDown = (ev) => { - if (Spotlight.focus()) { - ev.stopPropagation(); - ev.preventDefault(); - - handleNext(); - } + ev.stopPropagation(); + ev.preventDefault(); + handleNext(); }; return ( @@ -571,6 +577,7 @@ export default function HotPicksPanel({ panelInfo }) { className={css.hotPicks} cbScrollTo={getScrollTo} onWheel={handleWheel} + onScrollStop={_onScrollStop} scrollOptions={{ noScrollByWheel: true }} > {components.map((component, index) => ( diff --git a/com.twin.app.shoptime/src/views/HotPicksPanel/Type/TCFI/TCFI.jsx b/com.twin.app.shoptime/src/views/HotPicksPanel/Type/TCFI/TCFI.jsx index daa90860..8449aa58 100644 --- a/com.twin.app.shoptime/src/views/HotPicksPanel/Type/TCFI/TCFI.jsx +++ b/com.twin.app.shoptime/src/views/HotPicksPanel/Type/TCFI/TCFI.jsx @@ -112,6 +112,8 @@ export default function TCFI({ onClick={handleItemClick} >
@@ -211,6 +212,8 @@ export default function TCFV_4({ onBlur={onVideoBlur} >