Usage
Signature:
interface MasonryLayoutElement
Typescript Import Format
//To typecheck the element APIs, import as below.
import { MasonryLayoutElement } from "ojs/ojmasonrylayout";
//For the transpiled javascript to load the element's module, import as below
import "ojs/ojmasonrylayout";
For additional information visit:
Note: Application logic should not interact with the component's properties or invoke its methods until the BusyContext indicates that the component is ready for interaction.
Styling Classes
-
Category: Tile Size
-
Masonry tiles can be of pre-defined sizes spanning 1 to 3 columns and rows. There is a specific style class for each of the supported sizes. Use these classes on child elements of oj-masonry-layout.
Class template:
-
.oj-masonrylayout-tile-
[tile-size]Note: Square brackets signify required token substitutions whereas parentheses signify optional token substitutions.
-
Values for
[tile-size]Value (required) Name Description 1x1Tile 1x1 A tile that spans 1 column and 1 row. 1x2Tile 1x2 A tile that spans 1 column and 2 rows. 1x3Tile 1x3 A tile that spans 1 column and 3 rows. 2x1Tile 2x1 A tile that spans 2 columns and 1 row. 2x2Tile 2x2 A tile that spans 2 columns and 2 rows. 2x3Tile 2x3 A tile that spans 2 columns and 3 rows. 3x1Tile 3x1 A tile that spans 3 columns and 1 row. 3x2Tile 3x2 A tile that spans 3 columns and 2 rows. 3x3Tile 3x3 A tile that spans 3 columns and 3 rows.
Example
<oj-masonry-layout> <div class="oj-masonrylayout-tile-1x1"> <!-- Content 1 --> </div> <div class="oj-masonrylayout-tile-2x3"> <!-- Content 2 --> </div> </oj-masonry-layout> -
-
CSS Variables
-
Masonry Layout Tile CSS
| Name | Type | Description |
|---|---|---|
--oj-masonry-layout-tile-width |
<length> | Masonry layout tile width |
--oj-masonry-layout-tile-height |
<length> | Masonry layout tile height |
Slots
JET components that allow child content support slots. Please see the slots section of the JET component overview doc for more information on allowed slot content and slot types.
-
Default
-
<oj-masonry-layout> accepts arbitrary direct child elements that can be sized and positioned, which it will lay out as a grid of tiles. Each direct child element must be styled using one of the predefined
oj-masonrylayout-tile-CxRstyle classes to specify the size of that tile. A tile can span multiple columns and/or rows. -
contextMenu
-
The contextMenu slot is set on the
oj-menuwithin this element. This is used to designate the JET Menu that this component should launch as a context menu on right-click, Shift-F10, Press & Hold, or component-specific gesture. If specified, the browser's native context menu will be replaced by the JET Menu specified in this slot.The application can register a listener for the Menu's ojBeforeOpen event. The listener can cancel the launch via event.preventDefault(), or it can customize the menu contents by editing the menu DOM directly, and then calling refresh() on the Menu.
To help determine whether it's appropriate to cancel the launch or customize the menu, the ojBeforeOpen listener can use component API's to determine which table cell, chart item, etc., is the target of the context menu. See the JSDoc of the individual components for details.
Keep in mind that any such logic must work whether the context menu was launched via right-click, Shift-F10, Press & Hold, or component-specific touch gesture.
Attributes
-
(nullable) reorder-handle :string
-
Specify the selector of the descendant DOM element in a
oj-masonry-layoutchild that can be used to reorder the child by drag-and-drop.This attribute value is
nullby default, meaning thatoj-masonry-layoutchildren cannot be reordered. If each child that can be reordered has an element with style class'my-reorder-handle', then thereorder-handleattribute would be specified as'.my-reorder-handle'.When specifying a
reorder-handle, the application should also specify a context menu with actions to cut and paste tiles as an accessible alternative to drag-and-drop reordering.To specify a context menu, see the documentation of oj-menu.
- Default Value:
null
Names
Item Name Property reorderHandleProperty change event reorderHandleChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-reorder-handle-changed -
translations :object|null
-
A collection of translated resources from the translation bundle, or
nullif this component has no resources. Resources may be accessed and overridden individually or collectively, as seen in the examples.If the component does not contain any translatable resource, the default value of this attribute will be
null. If not, an object containing all resources relevant to the component.If this component has translations, their documentation immediately follows this doc entry.
Names
Item Name Property translationsProperty change event translationsChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-translations-changed -
(nullable) translations.label-cut :string
-
Context menu text used for cutting a tile.
See the translations attribute for usage examples.
- Default Value:
"Cut"
- Since:
- 1.1.0
Names
Item Name Property translations.labelCut -
(nullable) translations.label-paste-after :string
-
Context menu text used for pasting a tile after another tile.
See the translations attribute for usage examples.
- Default Value:
"Paste After"
- Since:
- 1.1.0
Names
Item Name Property translations.labelPasteAfter -
(nullable) translations.label-paste-before :string
-
Context menu text used for pasting a tile before another tile.
See the translations attribute for usage examples.
- Default Value:
"Paste Before"
- Since:
- 1.1.0
Names
Item Name Property translations.labelPasteBefore
Events
-
ojAnimateEnd
-
Triggered when a default animation has ended.
- Deprecated:
-
Since Description 12.1.0This web component no longer supports this event.
- "insert" - when a tile is inserted
- "move" - when a tile is moved
- "remove" - when a tile is removed
- "resize" - when a tile is resized
- "reorder" - when a tile is reordered
Properties:
All of the event payloads listed below can be found under
event.detail. See Events and Listeners for additional information.Name Type Description actionstring The action that triggered the animation.
Supported values are:elementElement The element being animated. -
ojAnimateStart
-
Triggered when a default animation is about to start on the element.
The default animation can be cancelled by calling
event.preventDefault(), followed by a call toevent.detail.endCallback().event.detail.endCallback()should be called immediately afterevent.preventDefault()if the application merely wants to cancel animation, or it should be called when the custom animation ends if the application is invoking another animation function. Failure to callevent.detail.endCallback()may prevent the element from working properly.For more information on customizing animations, see the documentation of AnimationUtils.
The default animations are controlled via the theme (SCSS) : $masonryLayoutInsertAnimation: ((effect: "zoomIn", duration: $masonryLayoutAnimationDuration, timingFunction: "ease-in-out"), "fadeIn") !default; $masonryLayoutRemoveAnimation: ((effect: "zoomOut", duration: $masonryLayoutAnimationDuration, timingFunction: "ease-in-out"), "fadeOut") !default; $masonryLayoutMoveAnimation: (effect: "addTransition", duration: $masonryLayoutAnimationDuration, timingFunction: "ease-in-out", transitionProperties: ('top', 'left', 'right')) !default; $masonryLayoutResizeAnimation: (effect: "addTransition", duration: $masonryLayoutAnimationDuration, timingFunction: "ease-in-out", transitionProperties: ('width', 'height', 'top', 'left', 'right')) !default; $masonryLayoutReorderAnimation: (effect: "addTransition", duration: $masonryLayoutAnimationDurationFast, timingFunction: "ease-in-out", transitionProperties: ('width', 'height', 'top', 'left', 'right')) !default;- Deprecated:
-
Since Description 12.1.0This web component no longer supports this event.
- "insert" - when a tile is inserted
- "move" - when a tile is moved
- "remove" - when a tile is removed
- "resize" - when a tile is resized
- "reorder" - when a tile is reordered
Properties:
All of the event payloads listed below can be found under
event.detail. See Events and Listeners for additional information.Name Type Description actionstring The action that triggers the animation.
Supported values are:
Note that some animation effects may not look appropriate for a given action.elementElement The element being animated. endCallbackfunction():void If the event listener calls event.preventDefault to cancel the default animation, it must call the endCallback function after it finishes its own animation handling and any custom animation has ended. -
ojBeforeInsert
-
Triggered immediately before a tile is inserted. This event can be cancelled by calling
event.preventDefault().Properties:
All of the event payloads listed below can be found under
event.detail. See Events and Listeners for additional information.Name Type Description indexnumber The 0-based index into the set of rendered oj-masonry-layoutchildren where the tile will be inserted.tileElement The tile that is about to be inserted. -
ojBeforeRemove
-
Triggered immediately before a tile is removed. This event can be cancelled by calling
event.preventDefault().Properties:
All of the event payloads listed below can be found under
event.detail. See Events and Listeners for additional information.Name Type Description tileElement The tile that will be removed. -
ojBeforeReorder
-
Triggered immediately before a tile is reordered. This event can be cancelled by calling
event.preventDefault().Properties:
All of the event payloads listed below can be found under
event.detail. See Events and Listeners for additional information.Name Type Description fromIndexnumber The 0-based index into the set of rendered oj-masonry-layoutchildren from which the tile will be reordered.tileElement The tile that will be reordered. -
ojBeforeResize
-
Triggered immediately before a tile is resized. This event can be cancelled by calling
event.preventDefault().Properties:
All of the event payloads listed below can be found under
event.detail. See Events and Listeners for additional information.Name Type Description previousSizeStyleClassstring The previous size style class applied to the tile. sizeStyleClassstring The new size style class that will be applied to the tile. tileElement The tile that will be resized. -
ojInsert
-
Triggered immediately after a tile is inserted.
Properties:
All of the event payloads listed below can be found under
event.detail. See Events and Listeners for additional information.Name Type Description indexnumber The 0-based index into the set of rendered oj-masonry-layoutchildren where the tile was inserted.tileElement The tile that was inserted. -
ojRemove
-
Triggered immediately after a tile is removed.
Properties:
All of the event payloads listed below can be found under
event.detail. See Events and Listeners for additional information.Name Type Description tileElement The tile that was removed. -
ojReorder
-
Triggered immediately after a tile is reordered.
Properties:
All of the event payloads listed below can be found under
event.detail. See Events and Listeners for additional information.Name Type Description fromIndexnumber The 0-based index into the set of rendered oj-masonry-layoutchildren from which the tile was reordered.tileElement The tile that was reordered. toIndexnumber The 0-based index into the set of rendered oj-masonry-layoutchildren to which the tile was reordered. -
ojResize
-
Triggered immediately after a tile is resized.
Properties:
All of the event payloads listed below can be found under
event.detail. See Events and Listeners for additional information.Name Type Description previousSizeStyleClassstring The previous size style class applied to the tile. sizeStyleClassstring The new size style class applied to the tile. tileElement The tile that was resized.
Methods
-
getProperty(property) : {any}
-
Retrieves the value of a property or a subproperty. The return type will be the same as the type of the property as specified in this API document. If the method is invoked with an incorrect property/subproperty name, it returns undefined.
Parameters:
Name Type Description propertystring The property name to get. Supports dot notation for subproperty access. - Since:
- 4.0.0
Returns:
- Type
- any
Example
Get a single subproperty of a complex property:
let subpropValue = myComponent.getProperty('complexProperty.subProperty1.subProperty2'); -
insertTile(selector, index) : {void}
-
Insert a tile into the masonryLayout.
Parameters:
Name Type Description selectorstring Selector identifying the tile to insert. The tile does not need to be a child of the oj-masonry-layoutwhen this method is called. This method will reparent the tile to theoj-masonry-layout.indexnumber The 0-based index into the set of rendered oj-masonry-layoutchildren where the tile will be inserted.Returns:
- Type
- void
-
refresh : {void}
-
Refreshes the visual state of the masonryLayout. JET elements require a
refresh()after the DOM is programmatically changed underneath the element.This method does not accept any arguments.
Returns:
- Type
- void
-
removeTile(selector) : {void}
-
Remove a tile from the masonryLayout.
Parameters:
Name Type Description selectorstring Selector identifying the tile to remove. Returns:
- Type
- void
-
resizeTile(selector, sizeStyleClass) : {void}
-
Resize a tile in the masonryLayout.
Parameters:
Name Type Description selectorstring Selector identifying the tile to resize. sizeStyleClassstring New size style class to apply to the tile. Returns:
- Type
- void
-
setProperties(properties) : {void}
-
Performs a batch set of properties. The type of value for each property being set must match the type of the property as specified in this API document.
Parameters:
Name Type Description propertiesObject An object containing the property and value pairs to set. - Since:
- 4.0.0
Returns:
- Type
- void
Example
Set a batch of properties:
myComponent.setProperties({"prop1": "value1", "prop2.subprop": "value2", "prop3": "value3"}); -
setProperty(property, value) : {void}
-
Sets a property or a subproperty (of a complex property) and notifies the component of the change, triggering a [property]Changed event. The value should be of the same type as the type of the attribute mentioned in this API document.
Parameters:
Name Type Description propertystring The property name to set. Supports dot notation for subproperty access. valueany The new value to set the property to. - Since:
- 4.0.0
Returns:
- Type
- void
Example
Set a single subproperty of a complex property:
myComponent.setProperty('complexProperty.subProperty1.subProperty2', "someValue");