Expand all

abstract OO.ui.mixin.ClippableElement

Constructor

new OO.ui.mixin.ClippableElement([config])abstract #

Element that can be automatically clipped to visible boundaries.

Whenever the element's natural height changes, you have to call OO.ui.mixin.ClippableElement#clip to make sure it's still clipping correctly.

The dimensions of #$clippableContainer will be compared to the boundaries of the nearest scrollable container. If #$clippableContainer is too tall and/or too wide, then #$clippable will be given a fixed reduced height and/or width and will be made scrollable. By default, #$clippable and #$clippableContainer are the same element, but you can build a static footer by setting #$clippableContainer to an element that contains #$clippable and the footer.

Parameters:

Name Type Attributes Description
config Object optional

Configuration options

Properties:
Name Type Attributes Description
$clippable jQuery optional

Node to clip, assigned to #$clippable, omit to use #$element

$clippableContainer jQuery optional

Node to keep visible, assigned to #$clippableContainer, omit to use #$clippable

Source:
Element that can be automatically clipped to visible boundaries.

Methods

clip() → {OO.ui.Element}chainable #

Clip element to visible boundaries and allow scrolling when needed. You should call this method when the element's natural height changes.

Element will be clipped the bottom or right of the element is within 10px of the edge of, or overlapped by, the visible area of the nearest scrollable container.

Because calling clip() when the natural height changes isn't always possible, we also set max-height when the element isn't being clipped. This means that if the element tries to grow beyond the edge, something reasonable will happen before clip() is called.

Source:

Returns:

The element, for chaining

Type
OO.ui.Element
Clip element to visible boundaries and allow scrolling when needed.

getHorizontalAnchorEdge() → {string} #

Return the side of the clippable on which it is "anchored" (aligned to something else). ClippableElement will clip the opposite side when reducing element's width.

Classes that mix in ClippableElement should override this to return 'right' if their clippable is absolutely positioned and using 'right: Npx' (and not using 'left'). If your class also mixes in FloatableElement, this is handled automatically.

(This can't be guessed from the actual CSS because the computed values for 'left'/'right' are always in pixels, even if they were unset or set to 'auto'.)

When in doubt, 'left' (or 'right' in RTL) is a reasonable fallback.

Source:

Returns:

'left' or 'right'

Type
string
Return the side of the clippable on which it is "anchored" (aligned to something else).

getVerticalAnchorEdge() → {string} #

Return the side of the clippable on which it is "anchored" (aligned to something else). ClippableElement will clip the opposite side when reducing element's width.

Classes that mix in ClippableElement should override this to return 'bottom' if their clippable is absolutely positioned and using 'bottom: Npx' (and not using 'top'). If your class also mixes in FloatableElement, this is handled automatically.

(This can't be guessed from the actual CSS because the computed values for 'left'/'right' are always in pixels, even if they were unset or set to 'auto'.)

When in doubt, 'top' is a reasonable fallback.

Source:

Returns:

'top' or 'bottom'

Type
string
Return the side of the clippable on which it is "anchored" (aligned to something else).

isClipped() → {boolean} #

Check if the bottom or right of the element is being clipped by the nearest scrollable container.

Source:

Returns:

Part of the element is being clipped

Type
boolean
Check if the bottom or right of the element is being clipped by the nearest scrollable container.

isClippedHorizontally() → {boolean} #

Check if the right of the element is being clipped by the nearest scrollable container.

Source:

Returns:

Part of the element is being clipped

Type
boolean
Check if the right of the element is being clipped by the nearest scrollable container.

isClippedVertically() → {boolean} #

Check if the bottom of the element is being clipped by the nearest scrollable container.

Source:

Returns:

Part of the element is being clipped

Type
boolean
Check if the bottom of the element is being clipped by the nearest scrollable container.

isClipping() → {boolean} #

Check if the element will be clipped to fit the visible area of the nearest scrollable container.

Source:

Returns:

Element will be clipped to the visible area

Type
boolean
Check if the element will be clipped to fit the visible area of the nearest scrollable container.

setClippableContainer($clippableContainer) #

Set clippable container.

This is the container that will be measured when deciding whether to clip. When clipping, #$clippable will be resized in order to keep the clippable container fully visible.

If the clippable container is unset, #$clippable will be used.

Parameters:

Name Type Description
$clippableContainer jQuery | null

Container to keep visible, or null to unset

Source:
Set clippable container.

setClippableElement($clippable) #

Set clippable element.

If an element is already set, it will be cleaned up before setting up the new element.

Parameters:

Name Type Description
$clippable jQuery

Element to make clippable

Source:
Set clippable element.

setIdealSize([width], [height]) #

Set the ideal size. These are the dimensions #$clippable will have when it's not being clipped.

Parameters:

Name Type Attributes Description
width number | string optional

Width as a number of pixels or CSS string with unit suffix

height number | string optional

Height as a number of pixels or CSS string with unit suffix

Source:
Set the ideal size.

toggleClipping([clipping]) → {OO.ui.Element}chainable #

Toggle clipping.

Do not turn clipping on until after the element is attached to the DOM and visible.

Parameters:

Name Type Attributes Description
clipping boolean optional

Enable clipping, omit to toggle

Source:

Returns:

The element, for chaining

Type
OO.ui.Element
Toggle clipping.