dom-geometry

dojo/dom-geometry

Summary

This module defines the core dojo DOM geometry API.

See the dojo/dom-geometry reference documentation for more information.

Properties

boxModel

Defined by: dojo/dom-geometry

Methods

docScroll(doc)

Defined by dojo/dom-geometry

Returns an object with {node, x, y} with corresponding offsets.

Parameter Type Description
doc Document
Optional

Optional document to query. If unspecified, use win.doc.

Returns: Object | undefined

fixIeBiDiScrollLeft(scrollLeft,doc)

Defined by dojo/dom-geometry

In RTL direction, scrollLeft should be a negative value, but IE returns a positive one. All codes using documentElement.scrollLeft must call this function to fix this error, otherwise the position will offset to right when there is a horizontal scrollbar.

Parameter Type Description
scrollLeft Number
doc Document
Optional

Optional document to query. If unspecified, use win.doc.

Returns: Number | number

getBorderExtents(node,computedStyle)

Defined by dojo/dom-geometry

returns an object with properties useful for noting the border dimensions.

  • l/t/r/b = the sum of left/top/right/bottom border (respectively)
  • w = the sum of the left and right border
  • h = the sum of the top and bottom border

The w/h are used for calculating boxes. Normally application code will not need to invoke this directly, and will use the ...box... functions instead.

Parameter Type Description
node DOMNode
computedStyle Object
Optional

This parameter accepts computed styles object. If this parameter is omitted, the functions will call dojo/dom-style.getComputedStyle to get one. It is a better way, calling dojo/dom-style.getComputedStyle once, and then pass the reference to this computedStyle parameter. Wherever possible, reuse the returned object of dojo/dom-style.getComputedStyle().

Returns: object

getContentBox(node,computedStyle)

Defined by dojo/dom-geometry

Returns an object that encodes the width, height, left and top positions of the node's content box, irrespective of the current box model.

Parameter Type Description
node DOMNode
computedStyle Object
Optional

This parameter accepts computed styles object. If this parameter is omitted, the functions will call dojo/dom-style.getComputedStyle to get one. It is a better way, calling dojo/dom-style.getComputedStyle once, and then pass the reference to this computedStyle parameter. Wherever possible, reuse the returned object of dojo/dom-style.getComputedStyle().

Returns: object

getIeDocumentElementOffset(doc)

Defined by dojo/dom-geometry

returns the offset in x and y from the document body to the visual edge of the page for IE

The following values in IE contain an offset:

event.clientX
event.clientY
node.getBoundingClientRect().left
node.getBoundingClientRect().top

But other position related values do not contain this offset,

such as node.offsetLeft, node.offsetTop, node.style.left and node.style.top. The offset is always (2, 2) in LTR direction. When the body is in RTL direction, the offset counts the width of left scroll bar's width. This function computes the actual offset.

Parameter Type Description
doc Document
Optional

Optional document to query. If unspecified, use win.doc.

Returns: object

getMarginBox(node,computedStyle)

Defined by dojo/dom-geometry

returns an object that encodes the width, height, left and top positions of the node's margin box.

Parameter Type Description
node DOMNode
computedStyle Object
Optional

This parameter accepts computed styles object. If this parameter is omitted, the functions will call dojo/dom-style.getComputedStyle to get one. It is a better way, calling dojo/dom-style.getComputedStyle once, and then pass the reference to this computedStyle parameter. Wherever possible, reuse the returned object of dojo/dom-style.getComputedStyle().

Returns: object

getMarginExtents(node,computedStyle)

Defined by dojo/dom-geometry

returns object with properties useful for box fitting with regards to box margins (i.e., the outer-box).

  • l/t = marginLeft, marginTop, respectively
  • w = total width, margin inclusive
  • h = total height, margin inclusive

The w/h are used for calculating boxes. Normally application code will not need to invoke this directly, and will use the ...box... functions instead.

Parameter Type Description
node DOMNode
computedStyle Object
Optional

This parameter accepts computed styles object. If this parameter is omitted, the functions will call dojo/dom-style.getComputedStyle to get one. It is a better way, calling dojo/dom-style.getComputedStyle once, and then pass the reference to this computedStyle parameter. Wherever possible, reuse the returned object of dojo/dom-style.getComputedStyle().

Returns: object

getMarginSize(node,computedStyle)

Defined by dojo/dom-geometry

returns an object that encodes the width and height of the node's margin box

Parameter Type Description
node DOMNode | String
computedStyle Object
Optional

This parameter accepts computed styles object. If this parameter is omitted, the functions will call dojo/dom-style.getComputedStyle to get one. It is a better way, calling dojo/dom-style.getComputedStyle once, and then pass the reference to this computedStyle parameter. Wherever possible, reuse the returned object of dojo/dom-style.getComputedStyle().

Returns: object

getPadBorderExtents(node,computedStyle)

Defined by dojo/dom-geometry

Returns object with properties useful for box fitting with regards to padding.

  • l/t/r/b = the sum of left/top/right/bottom padding and left/top/right/bottom border (respectively)
  • w = the sum of the left and right padding and border
  • h = the sum of the top and bottom padding and border

The w/h are used for calculating boxes. Normally application code will not need to invoke this directly, and will use the ...box... functions instead.

Parameter Type Description
node DOMNode
computedStyle Object
Optional

This parameter accepts computed styles object. If this parameter is omitted, the functions will call dojo/dom-style.getComputedStyle to get one. It is a better way, calling dojo/dom-style.getComputedStyle once, and then pass the reference to this computedStyle parameter. Wherever possible, reuse the returned object of dojo/dom-style.getComputedStyle().

Returns: object

getPadExtents(node,computedStyle)

Defined by dojo/dom-geometry

Returns object with special values specifically useful for node fitting.

Returns an object with w, h, l, t properties:

l/t/r/b = left/top/right/bottom padding (respectively)
w = the total of the left and right padding
h = the total of the top and bottom padding

If 'node' has position, l/t forms the origin for child nodes.

The w/h are used for calculating boxes. Normally application code will not need to invoke this directly, and will use the ...box... functions instead.

Parameter Type Description
node DOMNode
computedStyle Object
Optional

This parameter accepts computed styles object. If this parameter is omitted, the functions will call dojo/dom-style.getComputedStyle to get one. It is a better way, calling dojo/dom-style.getComputedStyle once, and then pass the reference to this computedStyle parameter. Wherever possible, reuse the returned object of dojo/dom-style.getComputedStyle().

Returns: object

isBodyLtr(doc)

Defined by dojo/dom-geometry

Returns true if the current language is left-to-right, and false otherwise.

Parameter Type Description
doc Document
Optional

Optional document to query. If unspecified, use win.doc.

Returns: Boolean | boolean

normalizeEvent(event)

Defined by dojo/dom-geometry

Normalizes the geometry of a DOM event, normalizing the pageX, pageY, offsetX, offsetY, layerX, and layerX properties

Parameter Type Description
event Object

position(node,includeScroll)

Defined by dojo/dom-geometry

Gets the position and size of the passed element relative to the viewport (if includeScroll==false), or relative to the document root (if includeScroll==true).

Returns an object of the form: { x: 100, y: 300, w: 20, h: 15 }. If includeScroll==true, the x and y values will include any document offsets that may affect the position relative to the viewport. Uses the border-box model (inclusive of border and padding but not margin). Does not act as a setter.

Parameter Type Description
node DOMNode | String
includeScroll Boolean
Optional

Returns: Object | object

setContentSize(node,box,computedStyle)

Defined by dojo/dom-geometry

Sets the size of the node's contents, irrespective of margins, padding, or borders.

Parameter Type Description
node DOMNode
box Object

hash with optional "w", and "h" properties for "width", and "height" respectively. All specified properties should have numeric values in whole pixels.

computedStyle Object
Optional

This parameter accepts computed styles object. If this parameter is omitted, the functions will call dojo/dom-style.getComputedStyle to get one. It is a better way, calling dojo/dom-style.getComputedStyle once, and then pass the reference to this computedStyle parameter. Wherever possible, reuse the returned object of dojo/dom-style.getComputedStyle().

setMarginBox(node,box,computedStyle)

Defined by dojo/dom-geometry

sets the size of the node's margin box and placement (left/top), irrespective of box model. Think of it as a passthrough to setBox that handles box-model vagaries for you.

Parameter Type Description
node DOMNode
box Object

hash with optional "l", "t", "w", and "h" properties for "left", "right", "width", and "height" respectively. All specified properties should have numeric values in whole pixels.

computedStyle Object
Optional

This parameter accepts computed styles object. If this parameter is omitted, the functions will call dojo/dom-style.getComputedStyle to get one. It is a better way, calling dojo/dom-style.getComputedStyle once, and then pass the reference to this computedStyle parameter. Wherever possible, reuse the returned object of dojo/dom-style.getComputedStyle().

© 2005–2015 The Dojo Foundation
Licensed under the AFL 2.1 and BSD 3-Clause licenses.
http://dojotoolkit.org/api/1.10/dojo/dom-geometry.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部