[홈패널] 롤링 수정
This commit is contained in:
@@ -34,6 +34,7 @@ export default function HomeBannerTemplate3() {
|
|||||||
const [bannerInfos, setBannerInfos] = useState([]);
|
const [bannerInfos, setBannerInfos] = useState([]);
|
||||||
const [vctpImage, setVctpImage] = useState(null);
|
const [vctpImage, setVctpImage] = useState(null);
|
||||||
const [wdthImage, setWdthImage] = useState(null);
|
const [wdthImage, setWdthImage] = useState(null);
|
||||||
|
const [onFocus, setOnFocus] = useState(true);
|
||||||
|
|
||||||
const homeMainContentsBannerInfos = useSelector(
|
const homeMainContentsBannerInfos = useSelector(
|
||||||
(state) => state.home.mainContentsData.homeMainContentsBannerInfos
|
(state) => state.home.mainContentsData.homeMainContentsBannerInfos
|
||||||
@@ -78,6 +79,15 @@ export default function HomeBannerTemplate3() {
|
|||||||
|
|
||||||
const onClickBanner = useCallback(() => {}, []);
|
const onClickBanner = useCallback(() => {}, []);
|
||||||
|
|
||||||
|
// 포커스가 들어오면 롤링 중지
|
||||||
|
const _onFocus = useCallback(() => {
|
||||||
|
setOnFocus(true);
|
||||||
|
}, [onFocus]);
|
||||||
|
|
||||||
|
const _onBlur = useCallback(() => {
|
||||||
|
setOnFocus(false);
|
||||||
|
}, [onFocus]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container className={css.homeTemplateBox}>
|
<Container className={css.homeTemplateBox}>
|
||||||
<div className={css.mainBox}>
|
<div className={css.mainBox}>
|
||||||
@@ -87,9 +97,19 @@ export default function HomeBannerTemplate3() {
|
|||||||
bannerInfos.map((item, index) => {
|
bannerInfos.map((item, index) => {
|
||||||
return item.banrLctnNo === "1" &&
|
return item.banrLctnNo === "1" &&
|
||||||
item.shptmDspyTpNm == "Rolling" ? (
|
item.shptmDspyTpNm == "Rolling" ? (
|
||||||
<Rolling bannerData={item} key={index} imageType={false} />
|
<Rolling
|
||||||
|
bannerData={item}
|
||||||
|
index={index}
|
||||||
|
key={index}
|
||||||
|
imageType={false}
|
||||||
|
/>
|
||||||
) : item.banrLctnNo === "1" && item.shptmDspyTpNm == "Random" ? (
|
) : item.banrLctnNo === "1" && item.shptmDspyTpNm == "Random" ? (
|
||||||
<Random bannerData={item} key={index} imageType={false} />
|
<Random
|
||||||
|
bannerData={item}
|
||||||
|
index={index}
|
||||||
|
key={index}
|
||||||
|
imageType={false}
|
||||||
|
/>
|
||||||
) : (
|
) : (
|
||||||
<CustomImage
|
<CustomImage
|
||||||
key={index}
|
key={index}
|
||||||
@@ -102,7 +122,11 @@ export default function HomeBannerTemplate3() {
|
|||||||
</SpottableComponent>
|
</SpottableComponent>
|
||||||
|
|
||||||
{/* 배너2 */}
|
{/* 배너2 */}
|
||||||
<SpottableComponent className={css.imgBox}>
|
<SpottableComponent
|
||||||
|
className={css.imgBox}
|
||||||
|
onFocus={_onFocus}
|
||||||
|
onBlur={_onBlur}
|
||||||
|
>
|
||||||
{bannerInfos &&
|
{bannerInfos &&
|
||||||
bannerInfos.map((item, index) => {
|
bannerInfos.map((item, index) => {
|
||||||
return item.banrLctnNo === "2" &&
|
return item.banrLctnNo === "2" &&
|
||||||
@@ -112,6 +136,7 @@ export default function HomeBannerTemplate3() {
|
|||||||
index={index}
|
index={index}
|
||||||
key={index}
|
key={index}
|
||||||
imageType={false}
|
imageType={false}
|
||||||
|
onFocus={onFocus}
|
||||||
/>
|
/>
|
||||||
) : item.banrLctnNo === "2" && item.shptmDspyTpNm == "Random" ? (
|
) : item.banrLctnNo === "2" && item.shptmDspyTpNm == "Random" ? (
|
||||||
<Random
|
<Random
|
||||||
@@ -138,10 +163,20 @@ export default function HomeBannerTemplate3() {
|
|||||||
bannerInfos.map((item, index) => {
|
bannerInfos.map((item, index) => {
|
||||||
return item.banrLctnNo === "3" &&
|
return item.banrLctnNo === "3" &&
|
||||||
item.shptmDspyTpNm == "Rolling" ? (
|
item.shptmDspyTpNm == "Rolling" ? (
|
||||||
<Rolling bannerData={item} key={index} imageType={true} />
|
<Rolling
|
||||||
|
bannerData={item}
|
||||||
|
index={index}
|
||||||
|
key={index}
|
||||||
|
imageType={true}
|
||||||
|
/>
|
||||||
) : item.banrLctnNo === "3" &&
|
) : item.banrLctnNo === "3" &&
|
||||||
item.shptmDspyTpNm == "Random" ? (
|
item.shptmDspyTpNm == "Random" ? (
|
||||||
<Random bannerData={item} key={index} imageType={true} />
|
<Random
|
||||||
|
bannerData={item}
|
||||||
|
index={index}
|
||||||
|
key={index}
|
||||||
|
imageType={true}
|
||||||
|
/>
|
||||||
) : (
|
) : (
|
||||||
<CustomImage
|
<CustomImage
|
||||||
key={index}
|
key={index}
|
||||||
@@ -161,10 +196,20 @@ export default function HomeBannerTemplate3() {
|
|||||||
bannerInfos.map((item, index) => {
|
bannerInfos.map((item, index) => {
|
||||||
return item.banrLctnNo === "4" &&
|
return item.banrLctnNo === "4" &&
|
||||||
item.shptmDspyTpNm == "Rolling" ? (
|
item.shptmDspyTpNm == "Rolling" ? (
|
||||||
<Rolling bannerData={item} key={index} imageType={true} />
|
<Rolling
|
||||||
|
bannerData={item}
|
||||||
|
index={index}
|
||||||
|
key={index}
|
||||||
|
imageType={true}
|
||||||
|
/>
|
||||||
) : item.banrLctnNo === "4" &&
|
) : item.banrLctnNo === "4" &&
|
||||||
item.shptmDspyTpNm == "Random" ? (
|
item.shptmDspyTpNm == "Random" ? (
|
||||||
<Random bannerData={item} key={index} imageType={true} />
|
<Random
|
||||||
|
bannerData={item}
|
||||||
|
index={index}
|
||||||
|
key={index}
|
||||||
|
imageType={true}
|
||||||
|
/>
|
||||||
) : (
|
) : (
|
||||||
<CustomImage
|
<CustomImage
|
||||||
key={index}
|
key={index}
|
||||||
|
|||||||
@@ -6,40 +6,85 @@ import React, {
|
|||||||
|
|
||||||
import VideoPlay from '@enact/sandstone/VideoPlayer';
|
import VideoPlay from '@enact/sandstone/VideoPlayer';
|
||||||
|
|
||||||
|
import image1 from '../../../../assets/Image/img-home-banner-h-01.png';
|
||||||
|
import image2 from '../../../../assets/Image/img-home-banner-h-01.png';
|
||||||
|
import image3 from '../../../../assets/Image/img-home-banner-v-01.png';
|
||||||
|
import image4 from '../../../../assets/Image/img-home-banner-v-02.png';
|
||||||
import CustomImage from '../../../components/CustomImage/CustomImage';
|
import CustomImage from '../../../components/CustomImage/CustomImage';
|
||||||
import HomeTodayDeal from '../HomeTodayDeal/HomeTodayDeal';
|
import HomeTodayDeal from '../HomeTodayDeal/HomeTodayDeal';
|
||||||
|
|
||||||
export default function RollingUnit({ bannerData, index, imageType }) {
|
// 더미 데이터
|
||||||
const bannerDetailInfos = bannerData.bannerDetailInfos[index];
|
const imgArr = [
|
||||||
const [rollingData, setRollingData] = useState();
|
{ img: image1, key: 1 },
|
||||||
|
{ img: image2, key: 2 },
|
||||||
|
{ img: image3, key: 3 },
|
||||||
|
{ img: image4, key: 4 },
|
||||||
|
];
|
||||||
|
|
||||||
|
export default function RollingUnit({ bannerData, index, imageType, onFocus }) {
|
||||||
|
const bannerDetailInfos = bannerData.bannerDetailInfos;
|
||||||
|
const bannerDetailInfosLength = bannerData.bannerDetailInfos.length;
|
||||||
|
|
||||||
|
const [rollingData, setRollingData] = useState([]);
|
||||||
const [shptmBanrTpNm, setShptmBanrTpNm] = useState();
|
const [shptmBanrTpNm, setShptmBanrTpNm] = useState();
|
||||||
|
const [count, setCount] = useState(10);
|
||||||
|
const [detailLenghth, setDetailLength] = useState();
|
||||||
|
const [startIndex, setStartIndex] = useState(0);
|
||||||
|
const [lastIndex, setLastIndex] = useState();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (bannerData) {
|
if (bannerData) {
|
||||||
setRollingData(bannerDetailInfos);
|
setRollingData(bannerDetailInfos);
|
||||||
setShptmBanrTpNm(bannerDetailInfos.shptmBanrTpNm);
|
setDetailLength(bannerDetailInfosLength);
|
||||||
|
setShptmBanrTpNm(bannerDetailInfos[startIndex].shptmBanrTpNm);
|
||||||
|
setLastIndex(bannerDetailInfosLength - 1);
|
||||||
}
|
}
|
||||||
}, [bannerData, index]);
|
}, [bannerData, shptmBanrTpNm]);
|
||||||
|
|
||||||
|
// 더미 데이터 테스트용
|
||||||
|
useEffect(() => {
|
||||||
|
// 포커스가 없을 경우에만 롤링
|
||||||
|
if (bannerDetailInfosLength === 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (onFocus === false) {
|
||||||
|
const id = setInterval(() => {
|
||||||
|
setCount((count) => count - 1);
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
if (count === 0) {
|
||||||
|
setStartIndex(startIndex + 1);
|
||||||
|
setCount(10);
|
||||||
|
clearInterval(id);
|
||||||
|
if (startIndex === lastIndex) {
|
||||||
|
setStartIndex(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return () => clearInterval(id);
|
||||||
|
}
|
||||||
|
}, [count, onFocus]);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{shptmBanrTpNm &&
|
{bannerDetailInfos &&
|
||||||
(shptmBanrTpNm === "Image Banner" ? (
|
bannerDetailInfos[startIndex].shptmBanrTpNm === "Image Banner" ? (
|
||||||
<CustomImage></CustomImage>
|
<CustomImage></CustomImage>
|
||||||
) : shptmBanrTpNm === "LIVE" || shptmBanrTpNm === "VOD" ? (
|
) : bannerDetailInfos[startIndex].shptmBanrTpNm === "LIVE" ||
|
||||||
<VideoPlay></VideoPlay>
|
bannerDetailInfos[startIndex].shptmBanrTpNm === "VOD" ? (
|
||||||
) : shptmBanrTpNm === "Today's Deals" ? (
|
<VideoPlay></VideoPlay>
|
||||||
<HomeTodayDeal
|
) : bannerDetailInfos[startIndex].shptmBanrTpNm === "Today's Deals" ? (
|
||||||
imgAlt={rollingData.imgAlt}
|
<HomeTodayDeal
|
||||||
imageName={rollingData.tmnlImgNm}
|
imgAlt={bannerDetailInfos[startIndex].imgAlt}
|
||||||
imgPath={rollingData.tmnlImgPath}
|
imageName={bannerDetailInfos[startIndex].tmnlImgNm}
|
||||||
priceInfo={rollingData.priceInfo}
|
imgPath={bannerDetailInfos[startIndex].tmnlImgPath}
|
||||||
productId={rollingData.prdtId}
|
priceInfo={bannerDetailInfos[startIndex].priceInfo}
|
||||||
productName={rollingData.prdtNm}
|
productId={bannerDetailInfos[startIndex].prdtId}
|
||||||
soldoutFlag={rollingData.soldoutFlag}
|
productName={bannerDetailInfos[startIndex].prdtNm}
|
||||||
isHorizontal={imageType} // TRUE, FALSE
|
soldoutFlag={bannerDetailInfos[startIndex].soldoutFlag}
|
||||||
/>
|
isHorizontal={imageType} // TRUE, FALSE
|
||||||
) : null)}
|
rolling={bannerDetailInfosLength === 1 ? false : true}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ export default function HomeTodayDeal({
|
|||||||
productName,
|
productName,
|
||||||
soldoutFlag,
|
soldoutFlag,
|
||||||
isHorizontal,
|
isHorizontal,
|
||||||
|
rolling,
|
||||||
...rest
|
...rest
|
||||||
}) {
|
}) {
|
||||||
const handleClick = useCallback(
|
const handleClick = useCallback(
|
||||||
@@ -74,14 +75,14 @@ export default function HomeTodayDeal({
|
|||||||
<img src={imgPath} />
|
<img src={imgPath} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* {rolling == true ? (
|
{rolling == true ? (
|
||||||
<>
|
<>
|
||||||
<div className={css.leftBtn}></div>
|
<div className={css.leftBtn}></div>
|
||||||
<div className={css.rightBtn}></div>
|
<div className={css.rightBtn}></div>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<></>
|
<></>
|
||||||
)} */}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user