Browse Source

fix navbar on product pae

master
azri 1 week ago
parent
commit
6100751da4
2 changed files with 5 additions and 2 deletions
  1. 2
    0
      src/components/Loader/Loader.jsx
  2. 3
    2
      src/components/Navbar/Navbar.jsx

+ 2
- 0
src/components/Loader/Loader.jsx View File

23
       width: "100%",
23
       width: "100%",
24
       height: "100%",
24
       height: "100%",
25
       backgroundColor: "white",
25
       backgroundColor: "white",
26
+      top:0,
27
+      left:0,
26
       position: "fixed",
28
       position: "fixed",
27
       display: (display) ? "flex" : "none",
29
       display: (display) ? "flex" : "none",
28
       alignItems:"center",
30
       alignItems:"center",

+ 3
- 2
src/components/Navbar/Navbar.jsx View File

108
 
108
 
109
   const swiperRef = useRef(null); // Create a ref for the Swiper instance
109
   const swiperRef = useRef(null); // Create a ref for the Swiper instance
110
   const [showHeader, setShowHeader] = useState(true);
110
   const [showHeader, setShowHeader] = useState(true);
111
-  const [isAtTop, setIsAtTop] = useState(true);
111
+  const [isAtTop, setIsAtTop] = useState(false);
112
   const [lastScrollPos, setLastScrollPos] = useState(0);
112
   const [lastScrollPos, setLastScrollPos] = useState(0);
113
   const [language, setLanguage] = useState('English');
113
   const [language, setLanguage] = useState('English');
114
   const dispatch = useDispatch();
114
   const dispatch = useDispatch();
128
   useEffect(() => {
128
   useEffect(() => {
129
 
129
 
130
     dispatch(fetchProducts())
130
     dispatch(fetchProducts())
131
+    if (window.location.pathname === "/") setIsAtTop(true);
131
 
132
 
132
     const handleScroll = () => {
133
     const handleScroll = () => {
133
-      setIsAtTop(window.scrollY < 20);
134
+      if (window.location.pathname === "/") setIsAtTop(window.scrollY < 20);
134
     };
135
     };
135
 
136
 
136
     window.addEventListener("scroll", handleScroll);
137
     window.addEventListener("scroll", handleScroll);

Loading…
Cancel
Save