Semi-sticky Navigation

This is a demonstration of my semisticky.js jQuery plugin, which lets you create a fixed navigation bar that shows and hides all or part of itself based on scroll behavior. If that description is confusing it's because I don't know what the proper term for this type of interaction is. If you know a better term, please tweet me at @wosephjeber.

Basically, it allows you to create a fixed element at the top of the window that hides all or part of itself when scrolling down and reveals itself when scrolling up. In this demo, I've broken the nav into two sections, hiding only the top section based on the scroll direction.

Here's the plugin code used on this page:


$('nav').semisticky({
  offsetLimit: $('.nav-actions').outerHeight(),
  onScroll: function(delta) {
    $('#delta').html(delta);
    $('#offset').html(this.currentOffsetAmount);
    $('#state').html(this.state);
  }
});  

I'm demonstrating the onScroll() callback by logging some data to that div in the corner. With each scroll event, the plugin calculates the change in scroll position, or delta. If you're scrolling down, the delta is positive. If you're scrolling up, the delta is negative.

And now for some filler text to make this page longer

Mumblecore Banksy Brooklyn 8-bit Vice. Semiotics Austin lomo you probably haven't heard of them ugh, scenester meditation Neutra banh mi master cleanse Carles migas disrupt. Next level drinking vinegar chia, try-hard scenester XOXO vegan post-ironic listicle +1 pug before they sold out. Health goth banh mi whatever, migas paleo Pinterest street art tousled. Trust fund Truffaut readymade quinoa, hoodie paleo cray heirloom lomo tattooed aesthetic flexitarian. Try-hard Godard hoodie, sartorial cornhole keffiyeh Bushwick Etsy art party retro swag post-ironic. Marfa food truck crucifix, health goth umami next level Shoreditch actually XOXO bespoke scenester heirloom McSweeney's selfies locavore.

Food truck actually Banksy, post-ironic kogi leggings 8-bit. Flexitarian occupy tofu American Apparel, normcore McSweeney's High Life. Four loko pickled cred stumptown vinyl. Pinterest Tumblr Helvetica, tattooed direct trade Vice vinyl Etsy. Pour-over mlkshk swag, freegan fingerstache food truck master cleanse aesthetic normcore artisan before they sold out Brooklyn. Meggings ugh Vice, wayfarers Echo Park viral PBR salvia blog church-key chambray. Lumbersexual DIY bicycle rights squid, single-origin coffee brunch raw denim plaid before they sold out irony.

Cold-pressed cronut tofu dreamcatcher, Pitchfork retro Pinterest literally jean shorts sartorial pork belly gluten-free mixtape quinoa. Carles ennui master cleanse butcher, salvia leggings viral readymade. Actually kale chips pork belly Marfa. Disrupt blog meggings Austin. Meggings iPhone flexitarian, mlkshk ennui Banksy Brooklyn mixtape Truffaut art party sriracha scenester hella Carles. DIY selvage hoodie, four loko occupy 3 wolf moon seitan twee bicycle rights wayfarers keffiyeh Thundercats Etsy taxidermy. Before they sold out normcore cred single-origin coffee meh cronut stumptown, Blue Bottle Vice pork belly quinoa Wes Anderson ethical next level.

Banjo hashtag Echo Park Williamsburg pickled, gentrify scenester. Aesthetic banjo Portland chillwave letterpress seitan selfies gluten-free, leggings mumblecore Etsy keffiyeh. Art party seitan sartorial deep v squid, 90's listicle. Mixtape selvage four loko, dreamcatcher Portland tattooed plaid kogi. Gluten-free cred sartorial YOLO keytar fixie. Lomo asymmetrical four loko Helvetica pork belly, forage four dollar toast post-ironic. Farm-to-table Williamsburg fanny pack, 3 wolf moon church-key cray selfies.

Delta: 0 px | Current offset: 0px | State: fixed