Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript

const ButtonNav = (props) => {
  const links = document.querySelector("#oi");
  function hoverHandler() {
    links.classList.add(styles.bigger);
  }

  const [fix, setFix] = useState(false);

  function setFixed() {
    if (window.scrollY >= 1) {
      setFix(true);
      const navbar = document.querySelector(`.${styles.navbar}`);
      navbar.classList.add(styles.sticky);
    } else {
      setFix(false);
    }
  }

  window.addEventListener("scroll", setFixed);

  const Circle = () => {
    return (
      <svg height="60" width="60">
        <circle cx="50" cy="50" r="10" />
      </svg>
    );
  };
  return (
    <div className={props.class + " " + styles.navbar}>
      <Link id="oi">
        <Circle />
      </Link>

      <Link>
        <Circle />
      </Link>
      <Link>
        <Circle />
      </Link>
    </div>
  );
};
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript
ADD COMMENT
Topic
Name
8+6 =