<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<!DOCTYPE html><html lang='en' class=''>
<head><script src='//production-assets.codepen.io/assets/editor/live/console_runner-079c09a0e3b9ff743e39ee2d5637b9216b3545af0de366d4b9aad9dc87e26bfd.js'></script><script src='//production-assets.codepen.io/assets/editor/live/events_runner-73716630c22bbc8cff4bd0f07b135f00a0bdc5d14629260c3ec49e5606f98fdd.js'></script><script src='//production-assets.codepen.io/assets/editor/live/css_live_reload_init-2c0dc5167d60a5af3ee189d570b1835129687ea2a61bee3513dee3a50c115a77.js'></script><meta charset='UTF-8'><meta name="robots" content="noindex"><link rel="shortcut icon" type="image/x-icon" href="//production-assets.codepen.io/assets/favicon/favicon-8ea04875e70c4b0bb41da869e81236e54394d63638a1ef12fa558a4a835f1164.ico" /><link rel="mask-icon" type="" href="//production-assets.codepen.io/assets/favicon/logo-pin-f2d2b6d2c61838f7e76325261b7195c27224080bc099486ddd6dccb469b8e8e6.svg" color="#111" /><link rel="canonical" href="https://codepen.io/DeptofJeffAyer/pen/ZOQMRZ?q=ScrollIndicator&limit=all&type=type-pens" />
<link rel='stylesheet prefetch' href='https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css'><link rel='stylesheet prefetch' href='https://fonts.googleapis.com/css?family=Open+Sans:700'>
<style class="cp-pen-styles">html {
scroll-behavior: smooth;
}
section {
height: 100vh;
}
section:nth-child(2n) {
color: white;
background: lightblue;
}
#scroll-indicator {
position: fixed;
top: 50%;
left: 5px;
-webkit-transform: translate(0, -50%);
transform: translate(0, -50%);
}
#scroll-indicator ul {
margin: 0;
padding: 0;
list-style: none;
}
#scroll-indicator li {
position: relative;
line-height: 36px;
}
#scroll-indicator li.active:before {
opacity: 0;
visibility: hidden;
-webkit-transform: translate(-50% 0);
transform: translate(-50% 0);
}
#scroll-indicator li.active a {
height: 44px;
}
#scroll-indicator li:before {
content: attr(data-title);
position: absolute;
bottom: -5px;
left: calc(100% + 20px);
font-weight: 700;
font-size: 12px;
line-height: 1;
text-transform: lowercase;
opacity: 0;
visibility: hidden;
-webkit-transition: left 0.25s cubic-bezier(0.455, 0.03, 0.515, 0.955), opacity 0.25s cubic-bezier(0.455, 0.03, 0.515, 0.955), visibility 0.25s cubic-bezier(0.455, 0.03, 0.515, 0.955);
transition: left 0.25s cubic-bezier(0.455, 0.03, 0.515, 0.955), opacity 0.25s cubic-bezier(0.455, 0.03, 0.515, 0.955), visibility 0.25s cubic-bezier(0.455, 0.03, 0.515, 0.955);
}
#scroll-indicator li:after {
content: '';
display: block;
position: absolute;
bottom: 0px;
left: 2px;
height: 2px;
width: calc(100% - 4px);
background: black;
pointer-events: none;
-webkit-transition: width 0.25s cubic-bezier(0.455, 0.03, 0.515, 0.955) 0.1s, height 0.25s cubic-bezier(0.455, 0.03, 0.515, 0.955) 0.1s, left 0.25s cubic-bezier(0.455, 0.03, 0.515, 0.955) 0.1s, bottom 0.25s cubic-bezier(0.455, 0.03, 0.515, 0.955) 0.1s;
transition: width 0.25s cubic-bezier(0.455, 0.03, 0.515, 0.955) 0.1s, height 0.25s cubic-bezier(0.455, 0.03, 0.515, 0.955) 0.1s, left 0.25s cubic-bezier(0.455, 0.03, 0.515, 0.955) 0.1s, bottom 0.25s cubic-bezier(0.455, 0.03, 0.515, 0.955) 0.1s;
}
#scroll-indicator li:hover:after {
left: 0px;
bottom: -1px;
width: 100%;
height: 4px;
-webkit-transition: width 0.15s cubic-bezier(0.455, 0.03, 0.515, 0.955), height 0.15s cubic-bezier(0.455, 0.03, 0.515, 0.955), left 0.15s cubic-bezier(0.455, 0.03, 0.515, 0.955), bottom 0.15s cubic-bezier(0.455, 0.03, 0.515, 0.955);
transition: width 0.15s cubic-bezier(0.455, 0.03, 0.515, 0.955), height 0.15s cubic-bezier(0.455, 0.03, 0.515, 0.955), left 0.15s cubic-bezier(0.455, 0.03, 0.515, 0.955), bottom 0.15s cubic-bezier(0.455, 0.03, 0.515, 0.955);
}
#scroll-indicator li:hover:before {
left: calc(100% + 10px);
opacity: 1;
visibility: visible;
}
#scroll-indicator a {
display: block;
position: relative;
height: 4px;
margin: 4px 0 0 0;
font-weight: bold;
font-size: 40px;
line-height: 36px;
font-family: 'Open Sans', sans-serif;
text-decoration: none;
color: black;
overflow: hidden;
-webkit-transition: height 0.25s cubic-bezier(0.455, 0.03, 0.515, 0.955);
transition: height 0.25s cubic-bezier(0.455, 0.03, 0.515, 0.955);
}
</style></head><body>
<section data-title='One' id='one'></section>
<section data-title='Two' id='two'></section>
<section data-title='Three' id='three'></section>
<section data-title='Four' id='four'></section>
<section data-title='Five' id='five'></section>
<section data-title='Six' id='six'></section>
<section data-title='Seven' id='seven'></section>
<section data-title='Eight' id='eight'></section>
<section data-title='Nine' id='nine'></section>
<nav id='scroll-indicator'></nav>
<script src='//production-assets.codepen.io/assets/common/stopExecutionOnTimeout-b2a7b3fe212eaa732349046d8416e00a9dec26eb7fd347590fbced3ab38af52e.js'></script>
<script >console.clear();
ScrollIndicator = (function(){
var scrollIndicator,
sections;
function onSectionClick(e) {
e.preventDefault();
if (!/li|a/.test(e.target.nodeName.toLowerCase())) {
return false;
}
ScrollIt(e.target);
}
function addEventListeners() {
scrollIndicator.addEventListener('click', onSectionClick);
}
function update(val) {
var winOffset = window.innerHeight * 0.25;
for (var i = 0; i < sections.length; i++) {
var activeTitle = sections[i].getAttribute('data-title'),
activeSection = scrollIndicator.querySelector('[data-title=' + activeTitle + ']');
if (val >= (sections[i].offsetTop - winOffset) && val < sections[i].offsetTop + (sections[i].clientHeight - winOffset)) {
activeSection.className = 'active';
} else {
activeSection.removeAttribute('class');
}
}
}
function init() {
scrollIndicator = document.getElementById('scroll-indicator');
sections = document.querySelectorAll('section');
var ul = document.createElement('ul');
//build the scroll nav
for (var i = 0; i < sections.length; i++) {
var count = (i < 10 ? '0' : '') + (i + 1),
section = sections[i],
li = document.createElement('li'),
a = document.createElement('a'),
id = section.id;
li.setAttribute('data-title', section.getAttribute('data-title'));
a.innerHTML = count;
a.href = '#' + id;
li.appendChild(a);
ul.appendChild(li);
}
scrollIndicator.appendChild(ul);
addEventListeners();
}
document.addEventListener('DOMContentLoaded', init);
return {
update: update
}
})();
GlobalScroll = (function() {
var scrollPos;
function getValue() {
return scrollPos;
}
function scrollVal() {
scrollPos = window.pageYOffset || document.body.scrollTop;
ScrollIndicator.update(scrollPos);
requestAnimationFrame(scrollVal);
}
document.addEventListener('DOMContentLoaded', scrollVal);
})();
ScrollIt = function(target, time) {
var targetId = target.href.split('#')[1],
end = document.getElementById(targetId).offsetTop,
start = window.pageYOffset,
duration = time || 1000,
distance = end - start,
timeStart = Date.now(),
timeEnd = timeStart + duration,
tick, cachedTick;
//https://en.wikipedia.org/wiki/Smoothstep
function step(startTime, endTime, point) {
if (point <= startTime) { return 0; }
if (point >= endTime) { return 1; }
var x = (point - startTime) / (endTime - startTime);
return x*x*x*(x*(x*6 - 15) + 10);
}
(function loop() {
var now = Date.now(),
tick = start + (distance * step(timeStart, timeEnd, now));
window.scrollTo(0, Math.floor(tick));
if (now <= timeEnd) {
requestAnimationFrame(loop);
}
})();
}
//# sourceURL=pen.js
</script>
</body></html>