Skip to content

Instantly share code, notes, and snippets.

@tjdett
Created May 31, 2012 00:16
Show Gist options
  • Save tjdett/2839766 to your computer and use it in GitHub Desktop.
Save tjdett/2839766 to your computer and use it in GitHub Desktop.
Bottom-right pusher
// Works, but has odd side-effects with complex content
var handlePullBottomRight = function() {
_.chain($(".pull-bottom.pull-right"))
.map(function(v) { return $(v).parent(); })
.uniq()
.each(function(v) {
var pusher = $('<div></div>').addClass('pusher pull-right')
.css('width','0px');
var items = $(v).find(".pull-bottom.pull-right");
var itemsHeight = _.chain(items)
.map(function(v) { return $(v).outerHeight(true); })
.tap(function(v) { console.debug(v); })
.reduce(function(a,b) { return a + b; }, 0).value();
$(v).css('position', 'relative');
$(v).children(':first-child').before(pusher, items.detach()
.css('clear', 'right'));
var pusherHeightFunc = function() {
console.log("Recalculating height: "+pusher.parent().innerHeight()+" - "+itemsHeight);
return pusher.parent().innerHeight() - itemsHeight;
};
$(window).on('resize', pusherHeightFunc);
pusher.height(pusherHeightFunc);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment