Skip to content

Instantly share code, notes, and snippets.

@venugopalkathavate
Created July 25, 2016 10:53
Show Gist options
  • Save venugopalkathavate/02c866121cc2d5189956292205e5cac3 to your computer and use it in GitHub Desktop.
Save venugopalkathavate/02c866121cc2d5189956292205e5cac3 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Rveal Menu On Scroll</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css" charset="utf-8">
<style media="screen">
.animated {
-webkit-animation-duration: .5s;
animation-duration: .5s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}
.menu {
padding: 30px;
text-align: center;
box-shadow: 0 0 1px rgba(0,0,0,.15);
background: #ededed;
position: fixed;
top: 0;
left: 0;
width: 100%;
}
h3 {
height: 25em;
text-align: center;
}
h3:first-child {
margin-top: 10em;
}
</style>
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var previousScroll = 0,
menu = $(".menu");
$(window).scroll(function() {
var currentScroll = $(this).scrollTop();
if (currentScroll > previousScroll) {
menu.removeClass("slideInDown")
.addClass("slideOutUp")
.addClass("animated");
} else {
menu.removeClass("slideOutUp")
.addClass("slideInDown")
.addClass("animated");
}
previousScroll = currentScroll;
});
});
</script>
</head>
<body>
<div class="menu">
<h1>Menu Items Here</h1>
</div>
<div class="content">
<h3>Some text here (FIRST)</h3>
<h3>Some text here</h3>
<h3>Some text here</h3>
<h3>Some text here</h3>
<h3>Some text here</h3>
<h3>Some text here</h3>
<h3>Some text here (LAST)</h3>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment