EA Share Count – Make fixed on scroll

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' );
}
}
}
});
});
view raw global.js hosted with ❤ by GitHub
@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;
}
}
view raw style.css hosted with ❤ by GitHub

Bill Erickson

Bill Erickson is the co-founder and lead developer at CultivateWP, a WordPress agency focusing on high performance sites for web publishers.

About Me
Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk