A Pen by Erik Goens on CodePen.
Created
January 20, 2016 21:24
-
-
Save egoens/4a448f2b0e7de143eb2b to your computer and use it in GitHub Desktop.
Medium's hide header on scroll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<header> | |
<section class="left"> | |
<button class="fa fa-home"></button> | |
<button class="fa fa-angle-left"></button> | |
<button class="fa fa-angle-right"></button> | |
</section> | |
<section class="center"> | |
<h1> | |
Still Waiting for the Revolution After All These Years | |
<span class="metadata">AST - A100 | |
Course: | |
A100 - The Solar System • Section 00003</span> | |
</h1> | |
</section> | |
<section class="right"> | |
<button class="fa fa-search"></button> | |
<button class="fa fa-gear"></button> | |
<button class="fa fa-list"></button> | |
</section> | |
</header> | |
<main> | |
<img src="http://lorempixel.com/1000/600/people/1" alt="" /> | |
<p>Collaboratively administrate empowered markets via plug-and-play networks. Dynamically procrastinate B2C users after installed base benefits. Dramatically visualize customer directed convergence without revolutionary ROI.</p> | |
<p>Efficiently unleash cross-media information without cross-media value. Quickly maximize timely deliverables for real-time schemas. Dramatically maintain clicks-and-mortar solutions without functional solutions.</p> | |
<p>Completely synergize resource taxing relationships via premier niche markets. Professionally cultivate one-to-one customer service with robust ideas. Dynamically innovate resource-leveling customer service for state of the art customer service.</p> | |
<p>Objectively innovate empowered manufactured products whereas parallel platforms. Holisticly predominate extensible testing procedures for reliable supply chains. Dramatically engage top-line web services vis-a-vis cutting-edge deliverables.</p> | |
<img src="http://lorempixel.com/1000/600/people/2" alt="" /> | |
<p>Proactively envisioned multimedia based expertise and cross-media growth strategies. Seamlessly visualize quality intellectual capital without superior collaboration and idea-sharing. Holistically pontificate installed base portals after maintainable products.</p> | |
<p>Phosfluorescently engage worldwide methodologies with web-enabled technology. Interactively coordinate proactive e-commerce via process-centric "outside the box" thinking. Completely pursue scalable customer service through sustainable potentialities.</p> | |
<p>Collaboratively administrate turnkey channels whereas virtual e-tailers. Objectively seize scalable metrics whereas proactive e-services. Seamlessly empower fully researched growth strategies and interoperable internal or "organic" sources.</p> | |
<p>Collaboratively administrate empowered markets via plug-and-play networks. Dynamically procrastinate B2C users after installed base benefits. Dramatically visualize customer directed convergence without revolutionary ROI.</p> | |
<p>Efficiently unleash cross-media information without cross-media value. Quickly maximize timely deliverables for real-time schemas. Dramatically maintain clicks-and-mortar solutions without functional solutions.</p> | |
<p>Completely synergize resource taxing relationships via premier niche markets. Professionally cultivate one-to-one customer service with robust ideas. Dynamically innovate resource-leveling customer service for state of the art customer service.</p> | |
<p>Objectively innovate empowered manufactured products whereas parallel platforms. Holisticly predominate extensible testing procedures for reliable supply chains. Dramatically engage top-line web services vis-a-vis cutting-edge deliverables.</p> | |
<p>Proactively envisioned multimedia based expertise and cross-media growth strategies. Seamlessly visualize quality intellectual capital without superior collaboration and idea-sharing. Holistically pontificate installed base portals after maintainable products.</p> | |
<p>Phosfluorescently engage worldwide methodologies with web-enabled technology. Interactively coordinate proactive e-commerce via process-centric "outside the box" thinking. Completely pursue scalable customer service through sustainable potentialities.</p> | |
<img src="http://lorempixel.com/1000/600/people/3" alt="" /> | |
<p>Collaboratively administrate turnkey channels whereas virtual e-tailers. Objectively seize scalable metrics whereas proactive e-services. Seamlessly empower fully researched growth strategies and interoperable internal or "organic" sources.</p> | |
<p>Collaboratively administrate empowered markets via plug-and-play networks. Dynamically procrastinate B2C users after installed base benefits. Dramatically visualize customer directed convergence without revolutionary ROI.</p> | |
<p>Efficiently unleash cross-media information without cross-media value. Quickly maximize timely deliverables for real-time schemas. Dramatically maintain clicks-and-mortar solutions without functional solutions.</p> | |
<p>Completely synergize resource taxing relationships via premier niche markets. Professionally cultivate one-to-one customer service with robust ideas. Dynamically innovate resource-leveling customer service for state of the art customer service.</p> | |
<p>Objectively innovate empowered manufactured products whereas parallel platforms. Holisticly predominate extensible testing procedures for reliable supply chains. Dramatically engage top-line web services vis-a-vis cutting-edge deliverables.</p> | |
<p>Proactively envisioned multimedia based expertise and cross-media growth strategies. Seamlessly visualize quality intellectual capital without superior collaboration and idea-sharing. Holistically pontificate installed base portals after maintainable products.</p> | |
<p>Phosfluorescently engage worldwide methodologies with web-enabled technology. Interactively coordinate proactive e-commerce via process-centric "outside the box" thinking. Completely pursue scalable customer service through sustainable potentialities.</p> | |
<p>Collaboratively administrate turnkey channels whereas virtual e-tailers. Objectively seize scalable metrics whereas proactive e-services. Seamlessly empower fully researched growth strategies and interoperable internal or "organic" sources.</p> | |
<p>Collaboratively administrate empowered markets via plug-and-play networks. Dynamically procrastinate B2C users after installed base benefits. Dramatically visualize customer directed convergence without revolutionary ROI.</p> | |
<p>Efficiently unleash cross-media information without cross-media value. Quickly maximize timely deliverables for real-time schemas. Dramatically maintain clicks-and-mortar solutions without functional solutions.</p> | |
<p>Completely synergize resource taxing relationships via premier niche markets. Professionally cultivate one-to-one customer service with robust ideas. Dynamically innovate resource-leveling customer service for state of the art customer service.</p> | |
<img src="http://lorempixel.com/1000/600/people/4" alt="" /> | |
<p>Objectively innovate empowered manufactured products whereas parallel platforms. Holisticly predominate extensible testing procedures for reliable supply chains. Dramatically engage top-line web services vis-a-vis cutting-edge deliverables.</p> | |
<p>Proactively envisioned multimedia based expertise and cross-media growth strategies. Seamlessly visualize quality intellectual capital without superior collaboration and idea-sharing. Holistically pontificate installed base portals after maintainable products.</p> | |
<p>Phosfluorescently engage worldwide methodologies with web-enabled technology. Interactively coordinate proactive e-commerce via process-centric "outside the box" thinking. Completely pursue scalable customer service through sustainable potentialities.</p> | |
<p>Collaboratively administrate turnkey channels whereas virtual e-tailers. Objectively seize scalable metrics whereas proactive e-services. Seamlessly empower fully researched growth strategies and interoperable internal or "organic" sources.</p> | |
<p>Collaboratively administrate empowered markets via plug-and-play networks. Dynamically procrastinate B2C users after installed base benefits. Dramatically visualize customer directed convergence without revolutionary ROI.</p> | |
<p>Efficiently unleash cross-media information without cross-media value. Quickly maximize timely deliverables for real-time schemas. Dramatically maintain clicks-and-mortar solutions without functional solutions.</p> | |
<p>Completely synergize resource taxing relationships via premier niche markets. Professionally cultivate one-to-one customer service with robust ideas. Dynamically innovate resource-leveling customer service for state of the art customer service.</p> | |
<p>Objectively innovate empowered manufactured products whereas parallel platforms. Holisticly predominate extensible testing procedures for reliable supply chains. Dramatically engage top-line web services vis-a-vis cutting-edge deliverables.</p> | |
<p>Proactively envisioned multimedia based expertise and cross-media growth strategies. Seamlessly visualize quality intellectual capital without superior collaboration and idea-sharing. Holistically pontificate installed base portals after maintainable products.</p> | |
<p>Phosfluorescently engage worldwide methodologies with web-enabled technology. Interactively coordinate proactive e-commerce via process-centric "outside the box" thinking. Completely pursue scalable customer service through sustainable potentialities.</p> | |
<p>Collaboratively administrate turnkey channels whereas virtual e-tailers. Objectively seize scalable metrics whereas proactive e-services. Seamlessly empower fully researched growth strategies and interoperable internal or "organic" sources.</p> | |
<p>Collaboratively administrate empowered markets via plug-and-play networks. Dynamically procrastinate B2C users after installed base benefits. Dramatically visualize customer directed convergence without revolutionary ROI.</p> | |
<p>Efficiently unleash cross-media information without cross-media value. Quickly maximize timely deliverables for real-time schemas. Dramatically maintain clicks-and-mortar solutions without functional solutions.</p> | |
<p>Completely synergize resource taxing relationships via premier niche markets. Professionally cultivate one-to-one customer service with robust ideas. Dynamically innovate resource-leveling customer service for state of the art customer service.</p> | |
<p>Objectively innovate empowered manufactured products whereas parallel platforms. Holisticly predominate extensible testing procedures for reliable supply chains. Dramatically engage top-line web services vis-a-vis cutting-edge deliverables.</p> | |
<p>Proactively envisioned multimedia based expertise and cross-media growth strategies. Seamlessly visualize quality intellectual capital without superior collaboration and idea-sharing. Holistically pontificate installed base portals after maintainable products.</p> | |
<img src="http://lorempixel.com/1000/600/people/5" alt="" /> | |
<p>Phosfluorescently engage worldwide methodologies with web-enabled technology. Interactively coordinate proactive e-commerce via process-centric "outside the box" thinking. Completely pursue scalable customer service through sustainable potentialities.</p> | |
<p>Collaboratively administrate turnkey channels whereas virtual e-tailers. Objectively seize scalable metrics whereas proactive e-services. Seamlessly empower fully researched growth strategies and interoperable internal or "organic" sources.</p> | |
</main> | |
<footer></footer> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Hide Header on on scroll down | |
var didScroll; | |
var lastScrollTop = 0; | |
var delta = 5; | |
var navbarHeight = $('header').outerHeight(); | |
$(window).scroll(function(event){ | |
didScroll = true; | |
}); | |
setInterval(function() { | |
if (didScroll) { | |
hasScrolled(); | |
didScroll = false; | |
} | |
}, 250); | |
function showNav() { | |
$('header').removeClass('nav-up').addClass('nav-down'); | |
} | |
function hideNav() { | |
$('header').removeClass('nav-down').addClass('nav-up'); | |
} | |
function hasScrolled() { | |
var st = $(this).scrollTop(); | |
// Make sure they scroll more than delta | |
if(Math.abs(lastScrollTop - st) <= delta) | |
return; | |
// If they scrolled down and are past the navbar, add class .nav-up. | |
// This is necessary so you never see what is "behind" the navbar. | |
if (st > lastScrollTop && st > navbarHeight){ | |
// Scroll Down | |
hideNav(); | |
} else { | |
// Scroll Up | |
if(st + $(window).height() < $(document).height()) { | |
//$('header').removeClass('nav-up').addClass('nav-down'); | |
showNav(); | |
} | |
} | |
lastScrollTop = st; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import "https://fonts.googleapis.com/css?family=Roboto:400,300,700|Pacifico|Julius+Sans+One"; | |
$header-height: 70px; | |
$metadata-color: lighten(black,50%); | |
html, body { | |
padding: 0; | |
margin: 0; | |
height: 3000px; | |
font-size: 16px; | |
font-family: "Roboto"; | |
} | |
body { | |
padding-top: $header-height; // same as header height | |
} | |
header { | |
background: rgba(255,255,255,.95); | |
height: $header-height; | |
position: fixed; | |
top: 0; | |
transition: top 0.1s ease-in-out; | |
width: 100%; | |
border-bottom: 1px solid darken(white,5%); | |
box-sizing: content-box; | |
line-height: $header-height; | |
text-transform: uppercase; | |
font-family: sans-serif; | |
// trying flex | |
display: flex; | |
flex-flow: row wrap; | |
button { | |
height: $header-height; | |
width: $header-height; | |
background: transparent; | |
border: none; | |
color: lighten(black,30%); | |
cursor: pointer; | |
transition: .25s; | |
&:hover { | |
background: darken(white,2.5%); | |
} | |
&.fa { | |
font-size: 1.5rem; | |
} | |
&.slim { | |
width: $header-height/1.5; | |
} | |
} | |
.left { | |
//float: left; | |
flex: 1; | |
order: 1; | |
button { | |
float: left; | |
} | |
} | |
.center { | |
flex: 3; | |
order: 2; | |
position: relative; | |
h1 { | |
margin: 0; | |
padding: 0; | |
font-size: 1.35rem; | |
font-family: "Roboto"; | |
text-transform: none; | |
line-height: 1.2rem; | |
text-align: center; | |
position: absolute; | |
top: 50%; | |
left: 50%; | |
transform: translate(-50%,-50%); | |
width: 100%; | |
span { | |
display: block; | |
font-size: .8rem; | |
font-weight: 400; | |
color: $metadata-color; | |
} | |
} | |
} | |
.right { | |
//float: right; | |
flex: 1; | |
order: 3; | |
button { | |
float: right; | |
} | |
} | |
} | |
main { | |
width: 80%; | |
max-width: 740px; | |
margin: 3rem auto; | |
font-weight: 300; | |
line-height: 1.5rem; | |
img { | |
width: 100%; | |
} | |
} | |
// we'll add this class using javascript | |
.nav-up { | |
top: -($header-height + 1px); // same as header height. use variables in LESS/SASS | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment