|
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' ); |
|
} |
|
|
|
} |
|
|
|
} |
|
}); |
|
|
|
}); |