javascript - How does the Stackoverflow footer animation work? -


how stackoverflow footer animation work?

particularly clicking on 1 element (e.g. technology), expand more.

the main "trick" have elements present, not shown. shown lists given _visible class:

max-width: 200px; opacity: 1; 

and lists not shown default:

max-width: 0 opacity: 0 

when class added or removed, transition property all ease-in-out .15s nicely animates each element.

a jquery approach using $('selector').toggleclass('_visible');. site not using jquery toggle classes, achieves same result.

$('#tech, button').on('click', function() {    $('nav, button').toggleclass('_visible');  })
div {    display: flex;  }    div>* {    -webkit-flex: 1 auto;    flex: 1 auto;    -webkit-flex-flow: row nowrap;    flex-flow: row nowrap;    transition: ease-in-out .15s;  }    nav,  button {    max-width: 0;    opacity: 0;  }    nav>ul {    margin: 0;    list-style: none;    white-space: nowrap;  }    ._visible {    opacity: 1;    max-width: 200px;  }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <button><svg role="icon" class="svg-icon iconarrowleftalt" width="18" height="18" viewbox="0 0 18 18"><path d="m10.58 16l12 14.59 6.4 9 12 3.41 10.57 2l-7 7z"></path></svg></button>  <div>    <nav class="_visible">      <ul>        <li id=tech>technology</li>        <li>life / arts</li>        <li>culture / recreation</li>        <li>science</li>        <li>other</li>        <li>mobile</li>      </ul>    </nav>    <nav>      <ul>        <li>stack overflow</li>        <li>server fault</li>        <li>super user</li>        <li>web applications</li>        <li>ask ubuntu</li>        <li>webmasters</li>        <li>game development</li>      </ul>    </nav>    <nav>      <ul>        <li>tex - latex</li>        <li>software engineering</li>        <li>unix &amp; linux</li>        <li>ask different (apple)</li>        <li>wordpress development</li>        <li>geographic information systems</li>        <li>electrical engineering</li>      </ul>    </nav>    <nav>      <ul>        <li>android enthusiasts</li>        <li>information security</li>        <li>database administrators</li>        <li>drupal answers</li>        <li>sharepoint</li>        <li>user experience</li>        <li>mathematica</li>      </ul>    </nav>    <nav>      <ul>        <li>salesforce</li>        <li>expressionengine® answers</li>        <li>blender</li>        <li>network engineering</li>        <li>cryptography</li>        <li>code review</li>        <li>magento</li>      </ul>    </nav>    <nav>      <ul>        <li>software recommendations</li>        <li>signal processing</li>        <li>emacs</li>        <li>raspberry pi</li>        <li>programming puzzles &amp; code golf</li>        <li>ethereum</li>        <li>data science</li>      </ul>    </nav>    <nav class="_visible">      <ul>        <li>blog</li>        <li>facebook</li>        <li>twitter</li>        <li>linkedin</li>        <li>site design / logo © 2017 stack exchange inc</li>      </ul>    </nav>  </div>


Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -