diy-template-components 2.0.97 → 2.0.99

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.es.js CHANGED
@@ -1398,6 +1398,7 @@ function DesktopHeader({
1398
1398
  onDownloadAppTriggered,
1399
1399
  extraProps
1400
1400
  }) {
1401
+ const [isVisible, setIsVisible] = useState(false);
1401
1402
  const {
1402
1403
  isFixed = true
1403
1404
  } = header;
@@ -1422,6 +1423,24 @@ function DesktopHeader({
1422
1423
  }
1423
1424
  return optionsData;
1424
1425
  };
1426
+ useEffect(() => {
1427
+ if (!header?.effectivePrice) {
1428
+ return;
1429
+ }
1430
+ const handleScroll = () => {
1431
+ if (window.scrollY > 200) {
1432
+ setIsVisible(true);
1433
+ } else {
1434
+ setIsVisible(false);
1435
+ }
1436
+ };
1437
+ window.addEventListener('scroll', handleScroll);
1438
+ return () => {
1439
+ if (header?.effectivePrice) {
1440
+ window.removeEventListener('scroll', handleScroll);
1441
+ }
1442
+ };
1443
+ }, []);
1425
1444
  const moreContentFn = () => {
1426
1445
  let optionsArr = navData;
1427
1446
  let moreContent = [];
@@ -1475,7 +1494,7 @@ function DesktopHeader({
1475
1494
  };
1476
1495
  const OfferDetailsJSX = () => {
1477
1496
  console.log('header', header);
1478
- if (!header?.effectivePrice) {
1497
+ if (!header?.effectivePrice || !isVisible) {
1479
1498
  return null;
1480
1499
  }
1481
1500
  let conversions = extraProps?.conversions || 0;
@@ -1603,40 +1622,45 @@ function MobileHeader({
1603
1622
  isCustomWebsite
1604
1623
  });
1605
1624
  const [sideMenu, openSideMenu] = useState(false);
1625
+ const [isVisible, setIsVisible] = useState(false);
1606
1626
  const navEl = useRef(null);
1607
1627
  useLayoutEffect(() => {
1608
1628
  const body = navEl?.current?.ownerDocument?.body;
1609
1629
  if (body) {
1610
- console.log("here in nav");
1611
1630
  if (sideMenu) {
1612
1631
  // body?.setAttribute('style', 'overflow: hidden;');
1613
- console.log("here in nav before", body, header);
1614
1632
  body.style.overflow = 'hidden';
1615
- console.log("here in nav hidden after", body, header);
1616
1633
  } else {
1617
1634
  // body?.removeAttribute('style');
1618
1635
  body.style.overflow = '';
1619
- console.log("here in nav hidden else", body, header);
1620
1636
  }
1621
1637
  if (header?.effectivePrice) {
1622
- console.log("here in effectivePrice if before", body, header);
1623
1638
  body.style.marginBottom = '130px';
1624
- console.log("here in effectivePrice if after", body, header);
1625
1639
  } else {
1626
- console.log("here in effectivePrice else before", body, header);
1627
1640
  body.style.marginBottom = '';
1628
- console.log("here in effectivePrice else before", body, header);
1629
1641
  }
1630
1642
  }
1631
1643
  }, [sideMenu, header?.effectivePrice]);
1632
1644
  useEffect(() => {
1633
1645
  if (header?.effectivePrice) {
1634
- console.log("here in use effect");
1635
1646
  const body = navEl?.current?.ownerDocument?.body;
1636
1647
  if (body) {
1637
1648
  body.style.marginBottom = '130px';
1638
1649
  }
1650
+ const handleScroll = () => {
1651
+ if (window.scrollY > 200) {
1652
+ setIsVisible(true);
1653
+ } else {
1654
+ setIsVisible(false);
1655
+ }
1656
+ };
1657
+ window.addEventListener('scroll', handleScroll);
1639
1658
  }
1659
+ return () => {
1660
+ if (header?.effectivePrice) {
1661
+ window.removeEventListener('scroll', handleScroll);
1662
+ }
1663
+ };
1640
1664
  }, []);
1641
1665
  let downloadLink = null;
1642
1666
  const downloadAppText = countryCode === 'KR' ? '앱다운로드' : 'Download App';
@@ -1693,7 +1717,11 @@ function MobileHeader({
1693
1717
  }
1694
1718
  };
1695
1719
  const OfferDetailsJSX = () => {
1696
- console.log('header', header);
1720
+ console.log('offer details jsx', header);
1721
+ const body = navEl?.current?.ownerDocument?.body;
1722
+ if (body) {
1723
+ body.style.marginBottom = '130px';
1724
+ }
1697
1725
  let conversions = extraProps?.conversions || 0;
1698
1726
  const currentTimestamp = new Date().getTime();
1699
1727
  if (header?.isOfferActive && header?.endDate && header?.endDate && header?.endDate > currentTimestamp && (header?.offerPriceValidFor ? header.offerPriceValidFor - conversions > 0 : true)) {
@@ -1707,7 +1735,7 @@ function MobileHeader({
1707
1735
  return null;
1708
1736
  };
1709
1737
  const BottomSheetJSX = () => {
1710
- if (!header?.effectivePrice) {
1738
+ if (!header?.effectivePrice || !isVisible) {
1711
1739
  return null;
1712
1740
  }
1713
1741
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {