JSFiddle - React, Tailwind, and code Playground

by gavinfriel

HTML

<script src="https://fonts.googleapis.com/css?family=Montserrat"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<div class="tab-wrap">
  <ul class="tab-list">
    <li class="active"><a href="/software-delivery">Software Delivery</a></li>
    <li><a href="/consulting">Consulting</a></li>
    <li><a href="analytics">Analytics</a></li>
    <li><a href="/training">Training</a></li>
  </ul>
</div>

<div id="pre-footer"><p>pre-footer</p></div>
<div id="footer"><p>footer</p></div>

CSS

body {
  background-color: #fff;
  padding: 20px;
  height: 900px;
}

#pre-footer{
  background: red; 
  height: 600px;
  margin-top:400px; 
}

#footer{
  background:blue; 
  height: 300px;
}

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

.tab-wrap {
  width: 100%;
  height: 50px;
  border-top: 1px solid rgba(63, 70, 80, .15);
  text-align: center;
  position: fixed;
  bottom: 0;
  /*right:0;*/
  /*left:0;*/
  margin: 0 0 0 -20px;
  background-color: #fff;
  -webkit-transition: -webkit-transform 0.6s cubic-bezier(0.26, 0, 0, 1);
  -moz-transition: -moz-transform 0.6s cubic-bezier(0.26, 0, 0, 1);
  transition: transform 0.6s cubic-bezier(0.26, 0, 0, 1);
}

.tab-wrap.hidden {
  -webkit-transform: translateY(100%);
  -moz-transform: translateY(100%);
  -ms-transform: translateY(100%);
  -o-transform: translateY(100%);
  transform: translateY(100%);
}

.tab-list {
  display: inline-block;
  line-height: 50px;
  font-family: 'Montserrat', sans-serif;
  font-size: 13px;
  text-transform: uppercase;
  font-weight: medium;
}

.tab-wrap ul {
  padding-left: 0px !important;
}

.tab-list li {
  display: inline-block;
  width: 180px;
  text-align: center;
}

.tab-list li a {
  color: rgba(63, 70, 80, .5);
  text-decoration: none;
}

.tab-list li a:hover {
  cursor: pointer;
  color: rgba(63, 70, 80, .95);
  transition: all .1s ease-in-out;
}

.tab-list li.active a {
  color: rgba(63, 70, 80, .95);
}

JavaScript

/*var prev = 0;
var $window = $(window);
var tabwrap = $('.tab-wrap');
$window.on('scroll', function() {
  var scrollTop = $window.scrollTop();
  tabwrap.toggleClass('hidden', scrollTop > prev);
  prev = scrollTop;
});*/

$(document).ready(function() {
	var $window = $(window);
  var tabwrap = $('.tab-wrap');
  var prefooter = $('#pre-footer');
  $window.on('scroll', function() {
  	var scrollTop = $window.scrollTop();
    tabwrap.toggleClass('hidden', scrollTop > 300); /* Help! */
    /* .tabwrap should toggle class .hidden when #pre-footer is visible in window */
  });
});