diff --git a/projects/mybyte/components/navbar.tsx b/projects/mybyte/components/navbar.tsx index 9d3516d..4ec4899 100644 --- a/projects/mybyte/components/navbar.tsx +++ b/projects/mybyte/components/navbar.tsx @@ -2,6 +2,7 @@ import Link from "next/link"; import { useRouter } from "next/router"; import { useAuth } from "../context/AuthContext"; import { Events } from "../enums/events"; +import { useLayoutEffect } from "react"; const Navbar = ({ children }: { children: React.ReactNode }) => { const { user, logOut, currEvent, userInfo, user_type } = useAuth(); @@ -29,9 +30,31 @@ const Navbar = ({ children }: { children: React.ReactNode }) => { } }; + const isElementXPercentInViewport = function(el: Element, percentVisible: number) { + let + rect = el.getBoundingClientRect(), + windowHeight = (window.innerHeight || document.documentElement.clientHeight); + + return !( + Math.floor(100 - (((rect.top >= 0 ? 0 : rect.top) / +-rect.height) * 100)) < percentVisible || + Math.floor(100 - ((rect.bottom - windowHeight) / rect.height) * 100) < percentVisible + ) + }; + + useLayoutEffect(() => { + let element = document.getElementById("acdweafadaefd"); + if (element !== null && element !== undefined && isElementXPercentInViewport(element, 100)) { + let parent = element.parentElement; + if (parent !== null) { + parent.style.display = "grid"; + parent.style.alignItems = "center"; + } + } + }); + return ( -
Join your fellow hackers. Let's build the future, together.
- + Log in