Code to place a DOMNode relative to another DOMNode. Load using require(["dijit/place"], function(place){ ... }).
See the dijit/place reference documentation for more information.
Position node adjacent or kitty-corner to anchor such that it's fully visible in viewport.
Place node such that corner of node touches a corner of aroundNode, and that node is fully visible.
Parameter | Type | Description |
---|---|---|
node | DomNode | |
anchor | DomNode | dijit/place.__Rectangle | Either a DOMNode or a rectangle (object with x, y, width, height). |
positions | String[] | Ordered list of positions to try matching up.
|
leftToRight | Boolean | True if widget is LTR, false if widget is RTL. Affects the behavior of "above" and "below" positions slightly. |
layoutNode | Function |
Optional For things like tooltip, they are displayed differently (and have different dimensions) based on their orientation relative to the parent. This adjusts the popup based on orientation. |
placeAroundNode(node, aroundNode, {'BL':'TL', 'TR':'BR'});
This will try to position node such that node's top-left corner is at the same position
as the bottom left corner of the aroundNode (ie, put node below aroundNode, with left edges aligned). If that fails it will try to put the bottom-right corner of node where the top right corner of aroundNode is (ie, put node above aroundNode, with right edges aligned)
Positions node kitty-corner to the rectangle centered at (pos.x, pos.y) with width and height of padding.x 2 and padding.y 2, or zero if padding not specified. Picks first corner in corners[] where node is fully visible, or the corner where it's most visible.
Node is assumed to be absolutely or relatively positioned.
Parameter | Type | Description |
---|---|---|
node | DOMNode | The node to position |
pos | dijit/place.__Position | Object like {x: 10, y: 20} |
corners | String[] | Array of Strings representing order to try corners of the node in, like ["TR", "BL"]. Possible values are:
|
padding | dijit/place.__Position |
Optional Optional param to set padding, to put some buffer around the element you want to position. Defaults to zero. |
layoutNode | undefined | For things like tooltip, they are displayed differently (and have different dimensions) based on their orientation relative to the parent. This adjusts the popup based on orientation. |
Try to place node's top right corner at (10,20). If that makes node go (partially) off screen, then try placing bottom left corner at (10,20).
place(node, {x: 10, y: 20}, ["TR", "BL"])