Hide the Sidebar, then Show It!
Memanfaatkan kemunculan kelas .isFixed untuk menjalankan perintah memunculkan elemen. Fitur ini masih belum ada dalam plugin, tapi masih bisa diakali dengan pure JQuery - https://plus.google.com/108949996304093815163/about
by Taufik Nurrohman
August 04, 2012
HTML
<script src="http://hompimpa.googlecode.com/svn/trunk/StickyBar/js/jquery.stickybar.js"></script>
<h2>Sembunyikan, Lalu Tampilkan</h2>
<div></div>
CSS
body {
padding:10px;
height:3000px;
border-left:4px dashed #ccc;
}
div {
width:200px;
height:100px;
background-color:black;
color:white;
padding:15px;
position:relative;
margin:200px 0 0;
}
h2 {
font:bold 16px Times,Serif;
margin:0 0 10px;
}
JavaScript
$('div').css('opacity', 0).stickyBar(); // Buat jadi transparan
$(window).on("scroll", function() {
if ($('div').hasClass('isFixed')) {
// Tampilkan jika elemen memiliki kelas 'isFixed'
$('div').stop().animate({
opacity: 1
}, 400);
} else {
$('div').stop().animate({
opacity: 0
}, 100);
}
});