Constructor
new OO.ui.mixin.FloatableElement([config])abstract
#
Element that will stick adjacent to a specified container, even when it is inserted elsewhere in the document (for example, in an OO.ui.Window's $overlay).
The elements's position is automatically calculated and maintained when window is resized or the page is scrolled. If you reposition the container manually, you have to call #position to make sure the element is still placed correctly.
As positioning is only possible when both the element and the container are attached to the DOM and visible, it's only done after you call #togglePositioning. You might want to do this inside the #toggle method to display a floating popup, for example.
Parameters:
Name | Type | Attributes | Description | |||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
config |
Object |
optional |
Configuration options Properties:
|
- Source:
Element that will stick adjacent to a specified container, even when it is inserted elsewhere in the document (for example, in an OO.ui.Window's $overlay).
Methods
computePosition() → {Object}
#
Compute how #$floatable should be positioned based on the position of #$floatableContainer and the positioning settings. This is a helper for #position that shouldn't be called directly, but may be overridden by subclasses if they want to change or add to the positioning logic.
- Source:
Returns:
New position to apply with .css(). Keys are 'top', 'left', 'bottom' and 'right'.
- Type
- Object
Compute how #$floatable should be positioned based on the position of #$floatableContainer and the positioning settings.
isFloatableOutOfView() → {boolean}
#
Check if the floatable is hidden to the user because it was offscreen.
- Source:
Returns:
Floatable is out of view
- Type
- boolean
position() → {OO.ui.Element}chainable
#
Position the floatable below its container.
This should only be done when both of them are attached to the DOM and visible.
- Source:
Returns:
The element, for chaining
- Type
- OO.ui.Element
setFloatableContainer($floatableContainer)
#
Set floatable container.
The element will be positioned relative to the specified container.
Parameters:
Name | Type | Description |
---|---|---|
$floatableContainer |
jQuery
|
null
|
Container to keep visible, or null to unset |
- Source:
setFloatableElement($floatable)
#
Set floatable element.
If an element is already set, it will be cleaned up before setting up the new element.
Parameters:
Name | Type | Description |
---|---|---|
$floatable |
jQuery | Element to make floatable |
- Source:
setHorizontalPosition(position)
#
Change how the element is positioned horizontally.
Parameters:
Name | Type | Description |
---|---|---|
position |
string | 'before', 'after', 'start', 'end' or 'center' |
- Source:
setVerticalPosition(position)
#
Change how the element is positioned vertically.
Parameters:
Name | Type | Description |
---|---|---|
position |
string | 'below', 'above', 'top', 'bottom' or 'center' |
- Source:
togglePositioning([positioning]) → {OO.ui.Element}chainable
#
Toggle positioning.
Do not turn positioning on until after the element is attached to the DOM and visible.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
positioning |
boolean |
optional |
Enable positioning, omit to toggle |
- Source:
Returns:
The element, for chaining
- Type
- OO.ui.Element