Skip to content

Instantly share code, notes, and snippets.

@anandkumar
Created July 3, 2013 04:48
Show Gist options
  • Save anandkumar/5915509 to your computer and use it in GitHub Desktop.
Save anandkumar/5915509 to your computer and use it in GitHub Desktop.
<script type="text/javascript">
jQuery(document).ready(function($) {
// Share bar
if ($('body').hasClass('single')) {
var timeout = null; var entryShare = $('#social-widgets').first(); var entryContent =$('.entry-content').first();
$(window).scroll(function () {
var scrollTop = $(this).scrollTop();
if(!timeout) {
timeout = setTimeout(function() { timeout = null;
if (entryShare.css('position') !== 'fixed' && entryShare.offset().top < $(document).scrollTop()) {
entryContent.css('padding-top', entryShare.outerHeight() + 8);
entryShare.css({'z-index': 500, 'position': 'fixed', 'top': 0, 'width': entryContent.width()});
} else if ($(document).scrollTop() <= entryContent.offset().top) {
entryContent.css('padding-top', '');
entryShare.css({ 'position': '', 'z-index': '', 'width': ''});
}
}, 250);
}
});
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment