fixed no dismiss on nav bar
This commit is contained in:
		
							parent
							
								
									62b272c3b9
								
							
						
					
					
						commit
						48650545bd
					
				
					 3 changed files with 16 additions and 8 deletions
				
			
		| 
						 | 
					@ -37,10 +37,11 @@ const NavComponent: Component<NavProps> = props => {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const handleClickOutside = (event: MouseEvent) => {
 | 
					  const handleClickOutside = (event: MouseEvent) => {
 | 
				
			||||||
    const isLink = "href" in (event.target || {});
 | 
					    const isLink = "href" in (event.target || {});
 | 
				
			||||||
 | 
					    const isInBody = document.body.contains(event.target as Node);
 | 
				
			||||||
    if (
 | 
					    if (
 | 
				
			||||||
      isLink ||
 | 
					      isLink ||
 | 
				
			||||||
      (document.body.contains(event.target as Node) &&
 | 
					      !isInBody ||
 | 
				
			||||||
        !navRef.contains(event.target as Node))
 | 
					      (isInBody && !navRef.contains(event.target as Node))
 | 
				
			||||||
    ) {
 | 
					    ) {
 | 
				
			||||||
      setOpen(false);
 | 
					      setOpen(false);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -70,11 +71,8 @@ const NavComponent: Component<NavProps> = props => {
 | 
				
			||||||
      ref={navRef!}
 | 
					      ref={navRef!}
 | 
				
			||||||
    >
 | 
					    >
 | 
				
			||||||
      <div onclick={e => toggle(e)}>
 | 
					      <div onclick={e => toggle(e)}>
 | 
				
			||||||
        {open() ? (
 | 
					        <MenuToX class={`nav-icon ${open() ? "active" : ""}`} />
 | 
				
			||||||
          <MenuToX class="nav-icon" />
 | 
					        <XToMenu class={`nav-icon ${!open() ? "active" : ""}`} />
 | 
				
			||||||
        ) : (
 | 
					 | 
				
			||||||
          <XToMenu class="nav-icon" />
 | 
					 | 
				
			||||||
        )}
 | 
					 | 
				
			||||||
      </div>
 | 
					      </div>
 | 
				
			||||||
      <div
 | 
					      <div
 | 
				
			||||||
        id={open() ? "#qs_search" : ""}
 | 
					        id={open() ? "#qs_search" : ""}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -47,7 +47,6 @@ const TableOfContents: Component<TOCProps> = props => {
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  createEffect(() => {
 | 
					  createEffect(() => {
 | 
				
			||||||
    const tocRoot = document.getElementById("toc")!;
 | 
					 | 
				
			||||||
    if (open()) {
 | 
					    if (open()) {
 | 
				
			||||||
      window.addEventListener("click", handleClickOutside);
 | 
					      window.addEventListener("click", handleClickOutside);
 | 
				
			||||||
      document.body.style.overflow = "hidden";
 | 
					      document.body.style.overflow = "hidden";
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,6 +5,17 @@
 | 
				
			||||||
  display: none;
 | 
					  display: none;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.nav-icon {
 | 
				
			||||||
 | 
					  opacity: 0;
 | 
				
			||||||
 | 
					  position: absolute;
 | 
				
			||||||
 | 
					  transition: opacity 0.6s;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.nav-icon.active {
 | 
				
			||||||
 | 
					  opacity: 1;
 | 
				
			||||||
 | 
					  position: relative;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.nav-toggle {
 | 
					.nav-toggle {
 | 
				
			||||||
  position: unset;
 | 
					  position: unset;
 | 
				
			||||||
  height: 24px;
 | 
					  height: 24px;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue