Usage
Signature:
interface WaterfallLayoutElement<K extends (string | number),D>
Generic Parameters
Parameter Description K Type of key of the dataprovider D Type of data from the dataprovider
Typescript Import Format
//To typecheck the element APIs, import as below.
import { WaterfallLayoutElement } from "ojs/ojwaterfalllayout";
//For the transpiled javascript to load the element's module, import as below
import "ojs/ojwaterfalllayout";
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.
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.
-
itemTemplate
-
The
itemTemplateslot is used to specify the template for rendering each item in the WaterfallLayout. The slot content must be a <template> element.The content inside the template must have a single Element as the root node. It cannot have multiple root nodes, incluidng Text and Comment nodes. The root node also cannot be a JET Binding Element, you must wrap it with an Element node. If the content do contain multiple nodes, WaterfallLayout will take the first Element node it encountered and ignore the rest.
When the template is executed for each item, it will have access to the binding context containing the following properties:
- $current - an object that contains information for the current item. (See oj.ojWaterfallLayout.ItemTemplateContext)
Properties of $current:
Name Type Description dataD The data for the current item being rendered indexnumber The zero-based index of the current item during initial rendering. Note the index is not updated in response to item additions and removals. keyK The key of the current item being rendered
Attributes
-
data :(DataProvider.<K, D>|null)
-
The data for WaterfallLayout. Must be of type DataProvider. Please refer to the DataProvider section for key data type requirement.
- Default Value:
null
Names
Item Name Property dataProperty change event dataChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-data-changed -
scroll-policy :"loadAll"|"loadMoreOnScroll"
-
Specifies the mechanism used to scroll the data inside the WaterfallLayout. Possible values are: "loadMoreOnScroll", and "loadAll". When "loadMoreOnScroll" is specified, additional data is fetched when the user scrolls to the bottom of the WaterfallLayout. Note that the component must have a height specified or inside a height constraint element so that the component element is scrollable. When "loadAll" is specified, WaterfallLayout will fetch all the data when it is initially rendered.
- Default Value:
'loadMoreOnScroll'
Supported Values:
Value Description loadAllFetch and render all data. loadMoreOnScrollAdditional data is fetched when the user scrolls towards the bottom of the grid. Names
Item Name Property scrollPolicyProperty change event scrollPolicyChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-scroll-policy-changed -
scroll-policy-options :Object.<string, any>
-
The following options are supported:
- fetchSize: The number of items fetched each time when scroll to the end.
- maxCount: Maximum rows which will be displayed before fetching more rows will be stopped.
- scroller: The element or a CSS selector string to an element which WaterfallLayout uses to determine the scroll position as well as the maximum scroll position where scroll to the end will trigger a fetch. If not specified then the oj-waterfall-layout element is used.
Names
Item Name Property scrollPolicyOptionsProperty change event scrollPolicyOptionsChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-scroll-policy-options-changed -
scroll-policy-options.fetch-size :number
-
The number of items to fetch in each block.
- Default Value:
25
Names
Item Name Property scrollPolicyOptions.fetchSize -
scroll-policy-options.max-count :number
-
The maximum total number of items to fetch.
- Default Value:
500
Names
Item Name Property scrollPolicyOptions.maxCount -
scroll-policy-options.scroller :Element | keyof HTMLElementTagNameMap|keyof SVGElementTagNameMap|string | null
-
The element or a CSS selector string to an element which WaterfallLayout uses to determine the scroll position as well as the maximum scroll position.
- Default Value:
null
Names
Item Name Property scrollPolicyOptions.scroller -
scroll-position :Object.<string, any>
-
The current scroll position of WaterfallLayout. The scroll position is updated when the vertical scroll position (or its scroller, as specified in scrollPolicyOptions.scroller) has changed. The value contains the y scroll position, the key of the item closest to the top of the viewport, as well as vertical offset from the position of the item to the actual scroll position.
The default value contains just the scroll position. Once data is fetched the 'key' and 'offsetY' sub-properties will be added. If there is no data then the 'key' sub-properties will not be available.
When setting the scrollPosition property, applications can change any combination of the sub-properties. If both key and y sub-properties are set at once then key will take precedent. If offsetY is specified, it will be used to adjust the scroll position from the position where the key of the item is located.
If a sparse object is set the other sub-properties will be populated and updated once WaterfallLayout has scrolled to that position.
Also, if scrollPolicy is set to 'loadMoreOnScroll' and the scrollPosition is set to a value outside of the currently rendered region, then the value of scrollPosition will be ignored.
Lastly, when a re-rendered is triggered by a refresh event from the DataProvider, or if the value for data attribute has changed, then the scrollPosition will by default remain at the top.- Supports writeback:
true
Names
Item Name Property scrollPositionProperty change event scrollPositionChangedProperty change listener attribute (must be of type function, see Events and Listeners for additional information.) on-scroll-position-changed -
scroll-position.key :K
-
The key of the item. If DataProvider is used for data and the key does not exist in the DataProvider or if the item has not been fetched yet, then the value is ignored.
Names
Item Name Property scrollPosition.key -
scroll-position.offset-y :number
-
The vertical offset in pixels relative to the item identified by key.
Names
Item Name Property scrollPosition.offsetY -
scroll-position.y :number
-
The vertical position in pixels.
- Default Value:
0
Names
Item Name Property scrollPosition.y
Methods
-
getProperty(property) : {any}
-
Retrieves a value for a property or a single subproperty for complex properties.
Parameters:
Name Type Description propertystring The property name to get. Supports dot notation for subproperty access. Returns:
- Type
- any
-
setProperties(properties) : {void}
-
Performs a batch set of properties.
Parameters:
Name Type Description propertiesObject An object containing the property and value pairs to set. Returns:
- Type
- void
-
setProperty(property, value) : {void}
-
Sets a property or a single subproperty for complex properties and notifies the component of the change, triggering a [property]Changed event.
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. Returns:
- Type
- void
Type Definitions
-
ItemTemplateContext<K,D>
-
Properties:
Name Type Description dataD The data for the current item being rendered indexnumber The zero-based index of the current item during initial rendering. Note the index is not updated in response to item additions and removals. keyK The key of the current item being rendered