2
Copyright (c) 2008, Yahoo! Inc. All rights reserved.
3
Code licensed under the BSD License:
4
http://developer.yahoo.net/yui/license.txt
7
YUI.add('node-screen', function(Y) {
10
* Extended Node interface for managing regions and screen positioning.
11
* Adds support for positioning elements and normalizes window size and scroll detection.
13
* @submodule node-screen
19
* Returns the inner width of the viewport (exludes scrollbar).
26
* Returns the inner height of the viewport (exludes scrollbar).
47
* Amount page has been scroll vertically
48
* @property docScrollX
54
* Amount page has been scroll horizontally
55
* @property docScrollY
61
Y.Node.getters[v] = Y.Node.wrapDOMMethod(v);
65
Y.Node.addDOMMethods([
67
* Gets the current position of the node in page coordinates.
68
* Nodes must be part of the DOM tree to have page coordinates
69
* (display:none or nodes not appended return false).
71
* @return {Array} The XY position of the node
76
* Set the position of the node in page coordinates, regardless of how the node is positioned.
77
* The node must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
79
* @param {Array} xy Contains X & Y values for new position (coordinates are page-based)
85
* Gets the current position of the node in page coordinates.
86
* Nodes must be part of the DOM tree to have page coordinates
87
* (display:none or nodes not appended return false).
89
* @return {Int} The X position of the node
94
* Set the position of the node in page coordinates, regardless of how the node is positioned.
95
* The node must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
97
* @param {Int} x X value for new position (coordinates are page-based)
103
* Gets the current position of the node in page coordinates.
104
* Nodes must be part of the DOM tree to have page coordinates
105
* (display:none or nodes not appended return false).
107
* @return {Int} The Y position of the node
112
* Set the position of the node in page coordinates, regardless of how the node is positioned.
113
* The node must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
115
* @param {Int} y Y value for new position (coordinates are page-based)
121
* Extended Node interface for managing regions and screen positioning.
122
* Adds support for positioning elements and normalizes window size and scroll detection.
124
* @submodule node-screen
129
* Returns a region object for the node
135
* Returns a region object for the node's viewport
136
* @property viewportRegion
143
Y.Node.getters[v] = Y.Node.wrapDOMMethod(v);
147
Y.Node.addDOMMethods([
149
* Determines whether or not the node is currently visible in the viewport.
150
* @method inViewportRegion
151
* @return {Boolean} Whether or not the node is currently positioned
152
* within the viewport's region
157
// these need special treatment to extract 2nd node arg
160
* Compares the intersection of the node with another node or region
162
* @param {Node|Object} node2 The node or region to compare with.
163
* @param {Object} altRegion An alternate region to use (rather than this node's).
164
* @return {Object} An object representing the intersection of the regions.
166
intersect: function(node1, node2, altRegion) {
167
if (node2 instanceof Y.Node) { // might be a region object
168
node2 = Y.Node.getDOMNode(node2);
170
return Y.DOM.intersect(node1, node2, altRegion);
174
* Determines whether or not the node is within the giving region.
176
* @param {Node|Object} node2 The node or region to compare with.
177
* @param {Boolean} all Whether or not all of the node must be in the region.
178
* @param {Object} altRegion An alternate region to use (rather than this node's).
179
* @return {Object} An object representing the intersection of the regions.
181
inRegion: function(node1, node2, all, altRegion) {
182
if (node2 instanceof Y.Node) { // might be a region object
183
node2 = Y.Node.getDOMNode(node2);
185
return Y.DOM.inRegion(node1, node2, all, altRegion);
191
}, '3.0.0pr2' ,{requires:['dom-screen']});