Skip to content

Instantly share code, notes, and snippets.

@eculver
Created April 4, 2011 22:20
Show Gist options
  • Save eculver/902589 to your computer and use it in GitHub Desktop.
Save eculver/902589 to your computer and use it in GitHub Desktop.
calculate bounding box coordinates
var BOTTOM_PADDING = 25;
// calculate the bounding box for the image
var containerNode = Y.one('#containerId');
// viewport height
var windowHeight = Y.one('body').get('winHeight');
// grab the box's width based on it's container
var boxWidth = parseInt(mediaPlayerNode.get('offsetWidth')) - 15; // 15px??
// bounding box height, width
var boxHeight = windowHeight - containerNode.getY() - BOTTOM_PADDING;
// bounding box coordinates
var topLeft = containerNode.getXY();
var topRight = [topLeft[0] + boxWidth, topLeft[1]];
var bottomLeft = [topLeft[0], topRight[1] + boxHeight];
var bottomRight = [topRight[0], topRight[1] + boxHeight];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment