JSFiddle - React, Tailwind, and code Playground
by Dedi Wibisono
HTML
<body>
<div class="holder">
<div class="sidebar">
<b>Peter Woyzbun</b>
<br/>
<br/>QIO
<br/>LUNCH
<br/>Posters
<br/>Great Economists
<br/>Westboro Creative
<br/>—
<br/>About
<br/>Contact</div>
<div class="main">
<div style='height:200px;' class='post'>
<p class="description" style="display: none;">content one description</p>
Website Other Stuff
<br/>Other Stuff
</div>
<div style='height:250px;' class='post'>
<p class="description" style="display: none;">content two description</p>
Packaging
</div>
<div style='height:350px;' class='post'>
<p class="description" style="display: none;">content three description</p>
Mobile Website
</div>
<div style='height:200px;' class='post'>
<p class="description" style="display: none;">content four description</p>
Proposal Book
</div>
<div id='date'></div>
<div style='height:800px;'></div>
</div>
</div>
</body>
CSS
body {
margin: 0px;
padding: 25px;
font-family: helvetica, arial;
font-size: 9pt;
}
.holder {
width: 100%;
}
.sidebar {
width: 200px;
font-family: helvetica, arial;
font-size: 9pt;
float: left;
position: fixed;
}
.main {
padding-left: 225px;
width: 640px;
font-family: helvetica, arial;
font-size: 9pt;
float: left;
}
.info {
width: 180px;
font-family: helvetica, arial;
font-size: 9pt;
float: left;
margin-left: 885px;
position: fixed;
}
p.content {
width: 180px;
border-top: 1px solid #CCCCCC;
padding-bottom: 5px;
padding-top: 5px;
margin: 0px;
}
.post {
border: 1px dashed grey;
margin-right: 50px;
margin-bottom: 20px;
}
#date {
position:fixed;
top:25px;
right:20px;
height: 45px;
width: 90px;
background: #ccc;
color:#000;
padding:2px;
}
.Desc {
width: 200px;
font-family: helvetica, arial;
font-size: 9pt;
float: left;
position: fixed;
background: grey;
}
JavaScript
$(window).load(function () {
$(window).on("scroll resize", function () {
var pos = $('#date').offset();
$('.post').each(function () {
if (pos.top >= $(this).offset().top && pos.top <= $(this).next().offset().top) {
var newDescr = $(this).find('.description').text();
var oldDescr = $( "#date" ).html();
$('#date').html(newDescr);
if(newDescr !== oldDescr) {
$( "#date" ).css('opacity', 0.4).animate({ 'opacity': '1',}, 200);
return;
}
}
});
});
$(document).ready(function () {
$(window).trigger('scroll'); // init the value
});
});