isMobile Is Set For Product Page

temp
Pedram Keshavarzi 3 years ago
parent 538f6cc110
commit 1cc2893bc9
  1. 14
      src/views/Product/index.js

@ -10,6 +10,7 @@ import Comment from "./Comment";
import Rate from "./Rate"; import Rate from "./Rate";
export const Product = ({ export const Product = ({
isMobile,
productType, productType,
getInfo, getInfo,
book, book,
@ -21,14 +22,25 @@ export const Product = ({
setHeaderOptions, setHeaderOptions,
}) => { }) => {
const [type, setType] = useState("physical"); const [type, setType] = useState("physical");
const [desktopContentTransform, setDesktopContentTransform] = useState(false);
useEffect(() => { useEffect(() => {
getInfo({ id: location.getId() }); getInfo({ id: location.getId() });
setHeaderOptions(headerOptions); setHeaderOptions(headerOptions);
if (!isMobile) {
window.addEventListener("scroll", () => {
if (window.scrollY >= 64) {
setDesktopContentTransform(() => true);
} else {
setDesktopContentTransform(() => false);
}
});
}
}, []); }, []);
return ( return (
<> <>
{/* Portrait */} {/* Portrait */}
{isMobile ? (
<div className="w-full flex flex-col bg-transparent px-4"> <div className="w-full flex flex-col bg-transparent px-4">
<header <header
className={`w-full flex ${ className={`w-full flex ${
@ -161,7 +173,7 @@ export const Product = ({
<Comment key={index} /> <Comment key={index} />
))} ))}
</div> </div>
</div> </div>) : <div>Desktop</div>}
</> </>
); );
}; };

Loading…
Cancel
Save