Pārlūkot izejas kodu

fix navbar on product pae

master
azri 1 nedēļu atpakaļ
vecāks
revīzija
6100751da4

+ 2
- 0
src/components/Loader/Loader.jsx Parādīt failu

@@ -23,6 +23,8 @@ const Loader = () => {
23 23
       width: "100%",
24 24
       height: "100%",
25 25
       backgroundColor: "white",
26
+      top:0,
27
+      left:0,
26 28
       position: "fixed",
27 29
       display: (display) ? "flex" : "none",
28 30
       alignItems:"center",

+ 3
- 2
src/components/Navbar/Navbar.jsx Parādīt failu

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

Notiek ielāde…
Atcelt
Saglabāt