dom-screen.js revision 76ca635d61eb3f9fb7c9d788a44fa8b1690aa138
* Adds position and region management functionality to DOM. // TODO: does caption matter? * Returns the inner height of the viewport (exludes scrollbar). * @return {Number} The current height of the viewport. * Returns the inner width of the viewport (exludes scrollbar). * @return {Number} The current width of the viewport. * @return {Number} The current height of the document. * @return {Number} The current width of the document. * Amount page has been scroll horizontally * @return {Number} The current amount the screen is scrolled horizontally. * Amount page has been scroll vertically * @return {Number} The current amount the screen is scrolled vertically. * Gets the current position of an element based on page coordinates. * Element must be part of the DOM tree to have page coordinates * (display:none or elements not appended return false). * @param element The target element * @return {Array} The XY position of the element // inline inDoc check for perf return function(
node) {
// manually calculate by crawling up offsetParents //Calculate the Top and Left border sizes (assumes pixels) // TODO: refactor with !! or just falsey // TODO: worth refactoring for TOP/LEFT only? // account for any scrolled ancestors //Firefox does something funky with borders when overflow is not visible. //Fix FIXED position -- add scrollbars }(),
// NOTE: Executing for loadtime branching * Gets the current X position of an element based on page coordinates. * Element must be part of the DOM tree to have page coordinates * (display:none or elements not appended return false). * @param element The target element * @return {Int} The X position of the element * Gets the current Y position of an element based on page coordinates. * Element must be part of the DOM tree to have page coordinates * (display:none or elements not appended return false). * @param element The target element * @return {Int} The Y position of the element * Set the position of an html element in page coordinates. * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false). * @param element The target element * @param {Array} xy Contains X & Y values for new position (coordinates are page-based) * @param {Boolean} noRetry By default we try and set the position a second time if the first fails if (
pos ==
'static') {
// default to relative * Set the X position of an html element in page coordinates, regardless of how the element is positioned. * The element(s) must be part of the DOM tree to have page coordinates (display:none or elements not appended return false). * @param element The target element * @param {Int} x The X values for new position (coordinates are page-based) * Set the Y position of an html element in page coordinates, regardless of how the element is positioned. * The element(s) must be part of the DOM tree to have page coordinates (display:none or elements not appended return false). * @param element The target element * @param {Int} y The Y values for new position (coordinates are page-based) * @description Swap the xy position with another node * @param {Node} node The node to swap with * @param {Node} otherNode The other node to swap with if (
mode !=
'CSS1Compat') {
// Quirks * Returns an Object literal containing the following about this element: (top, right, bottom, left) * @param {HTMLElement} element The DOM element. * @return {Object} Object literal containing the following about this element: (top, right, bottom, left) * Find the intersect information for the passes nodes. * @param {HTMLElement} element The first element * @param {HTMLElement | Object} element2 The element or region to check the interect with * @param {Object} altRegion An object literal containing the region for the first element if we already have the data (for performance i.e. DragDrop) * @return {Object} Object literal containing the following intersection data: (top, right, bottom, left, area, yoff, xoff, inRegion) * Check if any part of this node is in the passed region * @param {Object} node2 The node to get the region from or an Object literal of the region * $param {Boolean} all Should all of the node be inside the region * @param {Object} altRegion An object literal containing the region for this node if we already have the data (for performance i.e. DragDrop) * @return {Boolean} True if in region, false if not. * Check if any part of this element is in the viewport * @method inViewportRegion * @param {HTMLElement} element The DOM element. * @param {Boolean} all Should all of the node be inside the region * @param {Object} altRegion An object literal containing the region for this node if we already have the data (for performance i.e. DragDrop) * @return {Boolean} True if in region, false if not. * Returns an Object literal containing the following about the visible region of viewport: (top, right, bottom, left) * @return {Object} Object literal containing the following about the visible region of the viewport: (top, right, bottom, left) },
'@VERSION@' ,{
requires:[
'dom-core',
'dom-style']});