Skip to content

Plugins

Fatih Kadir Akın edited this page Apr 26, 2016 · 2 revisions

Bricklayer is a simple class that you can extend easily.

Plugin Development Guide

This is a simple plugin base:

Bricklayer.prototype.yourAwesomePlugin = function () {
  console.log(this);
}

Now you can use it as:

bricklayer.yourAwesomePlugin()

Element

You can reach out container element (first parameter of constructor) using this.element

new Bricklayer(document.querySelector('bricklayer'))

Element will be the container:

Bricklayer.prototype.yourAwesomePlugin = function () {
  console.log( this.element ) // this.element is `document.querySelector('bricklayer')`
}

Options

People can pass options to the Bricklayer, and your plugin can reach out them.

new Bricklayer(document.querySelector('bricklayer'), {awesomeOption: true})

Element will be the container:

Bricklayer.prototype.yourAwesomePlugin = function () {
  console.log( this.options.awesomeOption ) // true
}

Other Methods

Beside public methods, you can also use some helper methods which can help you when you develop plugins:

Method/Property Name Description Return Type Type
getColumnCount() Returns number of columns number Method
checkColumnCount() Recalculates column count void Method
findMinHeightColumn() Finds the minimum heighted column HTMLElement Method
getColumns() Returns all column elements [HTMLElement] Method
reorderElements(columnCount : number) Reorders elements by given columnCount parameter void Method
getElementsInOrder() Returns all elements in order [HTMLElement] Method
ruler .bricklayer-column-sizer Element HTMLElement Property
columnCount Calculated column count number Property
elements All elements in container [HTMLElement] Property