The array of context arguments for context-sensitive positioning.
The format of the array is: [contextElementOrId, overlayCorner, contextCorner, arrayOfTriggerEvents (optional), xyOffset (optional)]
, the
the 5 array elements described in detail below:
- contextElementOrId <String|HTMLElement>
- A reference to the context element to which the overlay should be aligned (or it's id).
- overlayCorner <String>
- The corner of the overlay which is to be used for alignment. This corner will be aligned to the
corner of the context element defined by the "contextCorner" entry which follows. Supported string values are:
"tr" (top right), "tl" (top left), "br" (bottom right), or "bl" (bottom left).
- contextCorner <String>
- The corner of the context element which is to be used for alignment. Supported string values are the same ones listed for the "overlayCorner" entry above.
- arrayOfTriggerEvents (optional) <Array[String|CustomEvent]>
-
By default, context alignment is a one time operation, aligning the Overlay to the context element when context configuration property is set, or when the align
method is invoked. However, you can use the optional "arrayOfTriggerEvents" entry to define the list of events which should force the overlay to re-align itself with the context element.
This is useful in situations where the layout of the document may change, resulting in the context element's position being modified.
The array can contain either event type strings for events the instance publishes (e.g. "beforeShow") or CustomEvent instances. Additionally the following
3 static container event types are also currently supported : "windowResize", "windowScroll", "textResize"
(defined in _TRIGGER_MAP private property).
- xyOffset <Number[]>
-
A 2 element Array specifying the X and Y pixel amounts by which the Overlay should be offset from the aligned corner. e.g. [5,0] offsets the Overlay 5 pixels to the left, after aligning the given context corners.
NOTE: If using this property and no triggers need to be defined, the arrayOfTriggerEvents property should be set to null to maintain correct array positions for the arguments.
For example, setting this property to ["img1", "tl", "bl"]
will
align the Overlay's top left corner to the bottom left corner of the
context element with id "img1".
Setting this property to ["img1", "tl", "bl", null, [0,5]
will
align the Overlay's top left corner to the bottom left corner of the
context element with id "img1", and then offset it by 5 pixels on the Y axis (providing a 5 pixel gap between the bottom of the context element and top of the overlay).
Adding the optional trigger values: ["img1", "tl", "bl", ["beforeShow", "windowResize"], [0,5]]
,
will re-align the overlay position, whenever the "beforeShow" or "windowResize" events are fired.