diff --git a/components/Footer.jsx b/components/Footer.jsx index 1fe9bc4..072223e 100644 --- a/components/Footer.jsx +++ b/components/Footer.jsx @@ -2,7 +2,13 @@ import React from "react"; const Footer = () => { return ( -
+

Copyright © 2021 BOT THK. All rights reserved.

); diff --git a/components/Header.jsx b/components/Header.jsx index e892164..c956398 100644 --- a/components/Header.jsx +++ b/components/Header.jsx @@ -5,7 +5,7 @@ import NProgress from "nprogress"; import { signout, isAuth } from "../actions/auth"; import Search from "./blog/Search"; import { useRouter } from "next/router"; -import { MenuOutlined } from "@ant-design/icons"; +import { MenuOutlined, SecurityScanTwoTone } from "@ant-design/icons"; import { APP_NAME } from "../config"; import Avatar from "../components/profile/Avatar"; @@ -15,6 +15,7 @@ const Header = () => { const router = useRouter(); const [menuActive, setMenuActive] = useState(false); const [userData, setUserData] = useState({}); + const [scrollDown, setScrollDown] = useState(false); const menuRef = useRef(null); const btnRef = useRef(null); @@ -34,6 +35,33 @@ const Header = () => { } }; + const handleScrolling = () => { + let currScrollPos; + let preScrollPos = + document.body.scrollTop || document.documentElement.scrollTop; + + window.addEventListener("scroll", () => { + currScrollPos = + document.body.scrollTop || document.documentElement.scrollTop; + + if (currScrollPos - preScrollPos > 0) { + setScrollDown(true); + } else { + setScrollDown(false); + } + preScrollPos = currScrollPos; + }); + }; + + useEffect(() => { + if (typeof window !== "undefined" && typeof document !== "undefined") { + handleScrolling(); + } + return () => { + window.removeEventListener("scroll", handleScrolling); + }; + }, []); + useEffect(() => { document.addEventListener("click", handleClickOutside, true); return () => { @@ -64,7 +92,9 @@ const Header = () => { }, []); return ( -