Some weeks ago I asked on Twitter and on OpenUI5 Slack channel if someone needed an external JS library wrapped in a custom-lib. One of the first replays was talking about Masonry, a stunning library to create cascading grid layout.
And here we are, this is the first of a series of on-demand openui5 custom library 😉
Masonry is a JavaScript grid layout library. It works by placing elements in optimal position based on available vertical space, sort of like a mason fitting stones in a wall. You’ve probably seen it in use all over the Internet.
Add the library to sap.ui5 dependencies list and configure the resourceRoots to point where you uploaded the custom library.
"sap.ui5": {
...
"dependencies": {
"minUI5Version": "1.30.0",
"libs": {
...
"it.designfuture.masonry": {}
}
},
"resourceRoots": {
"it.designfuture.masonry": "./resources/it/designfuture/masonry/"
}
}
Add the library to sap.ui5 dependencies list and configure the resourceRoots to point where you uploaded the custom library.
xmlns:df="it.designfuture.masonry"
And than you can simply add the MasonryLayout custom control
<df:MasonryLayout id="grid-layout" width="100%" height="1080px"
waitImageLoaded="false"
fitWidth="true"
resize="true"
columnWidth=".openui5-masonry-grid-sizer"
layoutComplete="onLayoutComplete"
removeComplete="onRemoveComplete"
imageLoadedAlways="onImageLoadedAlways"
imageLoadedDone="onImageLoadedDone"
imageLoadedFail="onImageLoadedFail"
imageLoadedProgress="onImageLoadedProgress">
<df:content>
<Image src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/82/orange-tree.jpg" />
<Image src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/82/submerged.jpg" />
<Image src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/82/look-out.jpg" />
<Image src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/82/one-world-trade.jpg" />
<Image src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/82/drizzle.jpg" />
<Image src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/82/cat-nose.jpg" />
<Image src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/82/contrail.jpg" />
<Image src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/82/golden-hour.jpg" />
<Image src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/82/flight-formation.jpg" />
</df:content>
</df:MasonryLayout>
If you would like to extend and customize the control, you can easily do that but re-building the code with just a simple Grunt command:
npm install
grunt build
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
5 | |
5 | |
5 | |
4 | |
4 | |
4 | |
4 | |
3 | |
3 |