Skip to content

Instantly share code, notes, and snippets.

@billerickson
Last active October 22, 2015 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billerickson/f4d790d5bc46b0a273e1 to your computer and use it in GitHub Desktop.
Save billerickson/f4d790d5bc46b0a273e1 to your computer and use it in GitHub Desktop.
jQuery(function($){
// Floating Sharing Buttons
var articleScrollHandling = {
allow: true,
reallow: function() {
articleScrollHandling.allow = true;
},
delay: 200 //(milliseconds) adjust to the highest acceptable value
};
$(window).scroll(function(){
if( articleScrollHandling.allow ) {
articleScrollHandling.allow = false;
setTimeout(articleScrollHandling.reallow, articleScrollHandling.delay);
if ( $('body').hasClass('single-post') ) {
var social = $('.ea-share-count-wrap.before_content');
var screen = $('.site-container');
var wrap = $('.site-inner .wrap');
var offset = $(social).offset().top - $(window).scrollTop();
var articleBottom = $('.entry-footer').offset().top - $(window).scrollTop();
var articleTop = $('h1.entry-title').offset().top - $(window).scrollTop();
var left = ( screen.width() - wrap.width() ) / 2 - social.width();
if( offset < 100 ) {
$(social).addClass('fixed');
$(social).css('left', left + 'px');
}
if( articleTop > 100 || articleBottom < 200 ) {
$(social).removeClass('fixed');
$(social).css('left', '-' + social.width() + 'px' );
}
}
}
});
});
@media only screen and (min-width: 1350px) {
.ea-share-count-wrap {
width: 150px;
position: absolute;
left: -150px;
}
.ea-share-count-wrap.fixed {
position: fixed;
left: 30px;
}
.ea-share-count-button.style-fancy {
margin: 0 0 16px;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment