Skip to content

Instantly share code, notes, and snippets.

@gerardpaapu
Created July 5, 2010 03:35
Show Gist options
  • Save gerardpaapu/463968 to your computer and use it in GitHub Desktop.
Save gerardpaapu/463968 to your computer and use it in GitHub Desktop.
function getContainerDimensions(elements, container){
// Returns an object { top: ..., right: ..., bottom: ..., left: ... }
// so that the dimensions will cover all of `elements`
//
// `container` is the element that the dimensions are relative to
return Seq.from(elements)
.invoke('getDimensions', container)
.pluck('top', 'right', 'bottom', 'left')
.unzip().apply(function (tops, rights, bottoms, lefts){
return {
'top': tops.min(), 'right': rights.max(),
'bottom': bottoms.max(), 'left': lefts.min()
};
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment