Class: Masonry

rgjs/masonry. Masonry

Create a new masonry object.
Based on https://medium.com/@_jh3y/how-to-the-masonry-layout-56f0fe0b19df.


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
Name Type Argument Description
order boolean <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});

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
container element <optional>

Optional. The element that contains the masonry panels.

panels elements <optional>

Optional. The masonry panels (children of container).

columns number <optional>

Optional. The number of columns.

opts object <optional>

Options are optional.

Properties
Name Type Argument Description
order boolean <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();