Giter Club home page Giter Club logo

hamburger-menu's Introduction

Hamburger Menu ๐Ÿ”

Creating and auditing a hamburger menu to result in 60fps animation

hamburger menu

Why ?

Many popular sites has hamburger menu. But most of them are janky because of the animations are less than 60fps. Instead of CPU to do our heavy rendering, we can make GPU to render a page to do some smooth animations.

How ?

Just by using CSS for animations

Example:

<!-- hamburger icon  -->
<div class="menu-icon">
  <svg width="24px" height="24px" viewBox="0 0 48 48">
    <path d="M6 36h36v-4H6v4zm0-10h36v-4H6v4zm0-14v4h36v-4H6z"></path>
  </svg>
</div>

<!-- menu  -->
<div class="menu">
  <div class="menu-logo">Hamburger Menu</div>
  <ul class="menu-list">
    <li>Home</li>
    <li>Shop</li>
    <li>Products</li>
    <li>Gallery</li>
    <li>Books</li>
    <li>Contact Us</li>
  <ul>
</div>

<div class="menu-overlay"></div>
.menu {
  width: 300px;
  height: 100%;
  position: fixed;
  bottom: 0;
  top: 0;
  transition: all 200ms ease-in; /* creates a smooth transition */
  transform: translateX(-103%); /* to hide menu */
  will-change: transform; /* hint to browser about upcoming transformation */
}

.menu-overlay {
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 99;
  visibility: hidden; /* to hide overlay */
}

+ little javascript

Result is a hamburger menu in 60fps, see the timeline recording done in chrome below.

Chrome Timeline Recording

Using JS

WIP

References

hamburger-menu's People

Contributors

gokulkrishh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.