Created
January 30, 2014 20:53
-
-
Save andreiglingeanu/8718435 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*########################################################################################## | |
Prepend <span> in Flickr Widget | |
##########################################################################################*/ | |
jQuery(document).ready(function($){ | |
$('.ewd-banner-fixed').closest('.widget.widget_text').addClass('affix-banner'); | |
var addFixed = false; | |
$(window).scroll(function (e) { | |
// config | |
var whenToFlickr = 0; // px | |
var whenToFlickrBottom = 80; // px | |
var fromBottom = 60; // px | |
var offsetY = $(window).scrollTop(); | |
var $flyingAdd = $('.affix-banner'); | |
if ($flyingAdd.length) { return; } | |
var bottom = $flyingAdd.prev().offset().top + $flyingAdd.prev().height(); | |
if (bottom - offsetY < -whenToFlickr) { | |
if (!$('.affix-banner').hasClass('fixed')) { | |
$('.affix-banner').addClass('fixed'); | |
addFixed = true; | |
}; | |
} else if ($('.affix-banner').hasClass('fixed')) { | |
$('.affix-banner').removeClass('fixed'); | |
addFixed = false; | |
} | |
if (addFixed) { | |
var scrollFromBottom = $(document).height() - offsetY - $(window).height(); | |
var bottomFooterTop = $('.td-footer-wrap').offset().top; | |
var footerOffset = (bottomFooterTop - offsetY) - ($flyingAdd.height() + whenToFlickrBottom); | |
$flyingAdd.css('margin-top', (footerOffset < 0 ? footerOffset - fromBottom : 0)); | |
}; | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment