Skip to content

Instantly share code, notes, and snippets.

@billerickson

billerickson/global.js Secret

Last active Oct 22, 2015
Embed
What would you like to do?
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
You can’t perform that action at this time.