new Masonry(container, panels, columns [, opts])
Parameters:
| Name | Type | Argument | Default | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
container |
element | The element that contains the masonry panels. |
||||||||||
panels |
elements | The masonry panels (children of container). |
||||||||||
columns |
number | The number of columns. |
||||||||||
opts |
object |
<optional> |
{} | Options are optional. Properties
|
Returns:
The masonry object.
- Type
- Masonry
Example
const container = document.querySelector('.masonry-container');
const elements = document.querySelectorAll('.masonry-item');
const masonry = new rgjs.masonry.Masonry(container, elements, 3, {order: true});
Methods
-
layout()
-
Lay out the masonry.
Returns:
The current masonry object.
- Type
- Masonry
Example
const container = document.querySelector('.masonry-container'); const elements = document.querySelectorAll('.masonry-item'); const masonry = new rgjs.masonry.Masonry(container, elements, 3, {order: true}).layout(); -
update( [container] [, panels] [, columns] [, opts])
-
Update the layout.
Note: All params are optional and fall back to what was passed to the Masonry instance's constructor. If a param is set, however, it will be stored and used for all future.layout()and.update()calls.Parameters:
Name Type Argument Description containerelement <optional>
Optional. The element that contains the masonry panels.
panelselements <optional>
Optional. The masonry panels (children of container).
columnsnumber <optional>
Optional. The number of columns.
optsobject <optional>
Options are optional.
Properties
Name Type Argument Description orderboolean <optional>
(Re)order the masonry panels.
Returns:
The masonry object.
- Type
- Masonry
Example
const container = document.querySelector('.masonry-container'); const elements = document.querySelectorAll('.masonry-item'); const masonry = new rgjs.masonry.Masonry(container, elements, 3, {order: true}).layout(); // ... masonry.update();