Class wpModules.util.Positioning
Constructor Attributes | Constructor Name and Description |
---|---|
Method Attributes | Method Name and Description |
---|---|
addPositionChangeListener(params)
Add a listener that polls a node for position and dimension
changes.
|
|
handle(params)
Positions the dialog and its pointer.
|
|
registerHandler(params)
Registers a position handlers with the provided name, that can be
used in conjunction with the #handle function
|
Method Detail
{listener the lister is started immediately when created, to
stop listening call its stop() function, start() function can be
called to resume listening.}
addPositionChangeListener(params)
Add a listener that polls a node for position and dimension
changes. If a change is detected the provided callback will get
called.
- Parameters:
- {JSON} params
- a JSON type object that allows to provide parameters that are used during registration
- {DOMNode} params.node
- the node to poll for position changes, if not specified the listener will not get created and return value will be undefined.
- {Function} params.callbackFn
- function that is to be called if a position or dimension change is detected for the node.
- {Window} params.targetWindow
- (optional) the window scope of the node, defaults to available window if not set.
- {Integer} params.pollInterval
- (optional) the interval the node is to be checked for reposition, default is 2000(ms).
- {Integer} params.tolerance
- (optional) the acceptable tolerance of node position change before calling the callback, defaults to 5 (pixels)
handle(params)
Positions the dialog and its pointer.
If a reference node is specified, the dialog is positioned at it's
right hand side (at it's left hand side in case of RTL). If the
dialog overlaps the reference node more than specified with the
maximum overlay, the dialog is placed on the opposite side of the
reference node if this can be done with less overlap.
- Parameters:
- {JSON} params
- a JSON type object that allows to provide the necessary parameters.
- {String} params.name
- the name of the handler to use for positioning
- {Object} params.targetWindow
- object to launch the dialog in
- {Object} params.node
- DOM node of the dialog
- {Object} params.refNode
- DOM node to align the dialog to
- {Object} params.targetBox
- object holding 'top', 'left', 'width', and 'height' to set position/dimensions with unaligned placement
- {Number} params.maxOverlay Optional, Default: 0.5
- maximum overlay value; may vary from 0.0 to 1.0 where 1.0 equals 100%
- {Integer} params.viewMargin Optional
- margin to keep dialog away from view port boundary
- {DOMNode} params.positionNode Optional
- the dom node that should be
used to apply the position, if the position should not be
set on
node
registerHandler(params)
Registers a position handlers with the provided name, that can be
used in conjunction with the #handle function
- Parameters:
- {JSON} params
- a JSON type object that allows to provide parameters that are used during registration
- {String} params.name
- the name of the handlers that are being registered
- {Function} params.nodeHandler Optional
- function that handles the node positioning. If this handler is not specified, a static targetBox needs to be provided on the #handle method.
- {Object} params.nodeHandler.view
- the dimensions of the viewport to which the sizing should happen
- {Object} params.nodeHandler.nodeBox
- the dimensions and position of the node that should be positioned
- {Object} params.nodeHandler.refBox
- the dimensions and position of the reference node.
- {Boolean} params.nodeHandler.right
- whether the node should be shown to the left or the right side of the reference node.
- {Integer} params.nodeHandler.viewMargin
- a margin that is applied between the border of the view and the node
- {Function} params.pointerHandler Optional
- function that handles the pointer positioning.
- {Object} params.pointerHandler.nodeBox
- the dimensions and position of the node that the pointer should be positioned to
- {Object} params.pointerHandler.refBox
- the dimensions and position of the reference node.
- {DOMNode} params.pointerHandler.pointer
- the DOM node of the pointer.
- {Boolean} params.pointerHandler.right
- whether the node should be shown to the left or the right side of the reference node.