1.0.6 • Published 7 months ago

brickolage v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

Brickolage 🧱

A tiny modern Masonry alternative, created with CSS3 Flexbox + vanilla JavaScript. Based on an elegant idea of Tobias Bjerrome Ahlin.

Update 2023: This is a slightly improved version of my own lib.

Demo

Features:

- Dependency-free.
  • Pure CSS3 Flexbox layout + a little bit of JavaScript. Number of columns is determined by item width via CSS.
  • Grid items stay untouched. No removing/adding DOM elements except separators.
  • No possible issues with absolutely positioned grid items, because it's a Flexbox layout as is.

Setting up

  1. Add a link to the css file in the <head> tag of your index.html:
<link rel="stylesheet" href="assets/brickolage.build.css">
  1. Insert before your closing <body> tag:
<script src="assets/brickolage.build.js"></script>
  1. Add markup to your index.html:
<ul class="brickolage--container">
	<li class="brickolage--item">
		...
	</li>

	<li class="brickolage--item">
		...
	</li>

	<li class="brickolage--item">
		...
	</li>
</ul>
  1. Initialize script in your app.js:
var fire = function() {
	var brcklg = new Brickolage();
}

( document.readyState === "complete" || ( document.readyState !== "loading" && ! document.documentElement.doScroll ) ) && fire() || document.addEventListener( "DOMContentLoaded", fire );

Options

OptionDescription
containerSpecify a selector or HTML element. Default: ".brickolage--container"
itemSpecify a selector or HTMLCollection. Default: ".brickolage--item"
separatorClassNameA column separator className. Default: "brickolage--separator"
separatorTagNameA column separator tagName. Default: "li"
originalOrderDetermines the items order style. Default: false

Be careful when changing default container, item and separatorClassName options, because of core styles.

Specify script options:

new Brickolage( {
	container: "[data-brickolage]",
	originalOrder: true
} );

Methods

MethodDescription
reLayoutUse to quickly update the container height and the items order.
reFreshTrigger this method after items were added or removed. Accepts new options.
destroyDestroys and cleans up the DOM. Returns elements to pre-initialized state. Callback function returns a destroyed instance.

Call method after initialization:

brcklg.Method();

License

MIT

1.0.6

7 months ago

1.0.5

7 months ago

1.0.4

7 months ago

1.0.3

7 months ago

1.0.2

7 months ago

1.0.1

7 months ago