Lightweight and independent Pinterest-like cascading grid layout library

Overview

Bricklayer is a Lightweight and Independent Pinterest-like Cascading Grid Layout Library

Join the chat at https://gitter.im/ademilter/bricklayer npm version Bower version

Image

  • 💎 Simpler than any other cascading grid layout tools.
  • ❄️ Lightweight, no fat. (1.5KB gzipped)
  • 👷 No frameworks required.
  • 💧 Responsive support with no glitches.
  • Easy configuration.
  • 💀 No inline styles, static positioning.
  • 📦 Integrates with jQuery, Angular.js and React.js easily.

Read Tutorial and Documentation →


Playgrounds

Are you using Bricklayer.js for your next project?

Let us know if you use this awesome library in your project and we'll add here!

These are the sites using Bricklayer!

Browser Support

This plugin works seamlessly with, Safari, Firefox, Chrome and all other modern browsers.

Contribution

Check out our awesome contributors! Maybe you want to buy some coffee for them ☕️

We need contributions for:

  • Improving documentation
  • Building fancy web pages
  • Typo fixes

Credits

License

Bricklayer - Cascading Grid Layouts

Copyright © 2016 Adem İlter

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Comments
  • Multiple bricklayers on one page

    Multiple bricklayers on one page

    I just tried your work. It works like magic, but only for one gallery on a page. I tried to use more generated galleries, where in every gallery i use bricklayer class. But it takes only first appearance and not the others. Can I ask you for help. Javascript amateur here, sorry.

    Do not really know if this is an issue of it or not.

    opened by Ernedar 9
  • Angular2 support

    Angular2 support

    This is rather a bug but more a call for help. I'm trying to get bricklayer work within my angular2/ionic2 app. This is what I have so far:

    HTML

    <button (click)="addBrick()">Add a brick</button>
    <section #bricklayer class="bricklayer"></section>
    

    JS

    export class MyPage {
      bricklayer: Bricklayer;
      @ViewChild('bricklayer') bricklayer:ElementRef;
    
      constructor() { }
    
      ngAfterViewInit() {
        console.log(this.bricklayer.nativeElement);
        this.bricklayer = new Bricklayer(this.bricklayer.nativeElement);
        console.log(this.bricklayer);
      }
    
      newBox() {
        var randomColor = '#' + Math.random().toString(16).substr(-6);
        var heights = [50, 90, 150, 190, 230];
        var randomHeight = heights[Math.floor(Math.random() * heights.length)];
        var box = document.createElement('div');
        box.className = 'box';
        box.style.backgroundColor = randomColor;
        box.style.height = randomHeight + "px";
        return box;
      }
    
      addBrick() {
        var box = this.newBox();
        box.innerHTML = (this.bricklayer.elements.length + 1);
        this.bricklayer.append(box);
      }
    }
    

    CSS

    .bricklayer {
      margin: 10px 5px;
    }
    
    .box {
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 30px;
      color: rgba(255, 255, 255, .6);
      margin-bottom: 10px;
    }
    

    The 2 console.logs (one for the HTML element and another one for the bricklayer reference) log out correct (as far as I can tell) but as soon as try to append a brick I get an error:

    TypeError: Cannot read property 'appendChild' of undefined
    
    opened by davidruisinger 6
  • Uncaught TypeError: Cannot read property 'appendChild' of undefined when changing view/route in SPA

    Uncaught TypeError: Cannot read property 'appendChild' of undefined when changing view/route in SPA

    Hello! Love your library!

    I've come across an issue when using bricklayer in a SPA (using Aurelia as the MVC framework). Using two simple routes/views: one is a 'menu' route/view with 2 instances of bricklayer for 2 different "module" menus on the same page. Bricklayer is initialized with the following after attaching the template/DOM to the window.

    var bricklayer = new Bricklayer(document.querySelector('#bricklayer-m' + mid));

    where mid is the module id, thus initializing bricklayer on both #bricklayer-m0 and #bricklayer-m1. Works perfect. Using a custom on('breakpoint') listener, columnCount shows the correct number when a breakpoint is reached.

    I then leave this menu route/view, going to a different route/view in the SPA, and then come back to the menu route/view again. The menu is built again and bricklayer is initialized again for each instance. Again, bricklayer appears to be working fine, like above.

    However, I'm now get this additional error whenever I resize the browser (Chrome). This error will fire twice on every browser resize, not just at the predefined breakpoints.

    Uncaught TypeError: Cannot read property 'appendChild' of undefined (anonymous function) @ bricklayer-node.js:147 Container.reorderElements @ bricklayer-node.js:145 (anonymous function) @ bricklayer-node.js:100 triggerEvent @ bricklayer-node.js:20 Container.checkColumnCount @ bricklayer-node.js:123 (anonymous function) @ bricklayer-node.js:98

    The custom on('breakpoint') listener displays columnCount as NaN. It's almost as if it's still looking for the two initial bricklayer instances, but is unable to find them (as they've been removed and reinitialized again upon changing routes).

    Any thoughts on this? I've also tried to delete each instance of bricklayer with bricklayer = null as well before navigating away from the menu view/route, but no luck there either. If more info is needed, let me know...thanks!

    enhancement 
    opened by nathanfiedler 6
  • ES6/2015 support

    ES6/2015 support

    Hi!

    I tried to use bricklayer in my ES6/babelified code and the import seems to fail:

    import Bricklayer from 'bricklayer'
    

    The Bricklayer results in an empty object.

    opened by nlemoine 5
  • Integration with WP default gallery

    Integration with WP default gallery

    Hello, i really dont know is this issue... i'm trying to integrate bricklayer with default WP gallery, i include all the stuff, and in developer tools i can see appended stuff, but columns are 100% width

    DEMO: http://hafizovic.ba/wp/246-2/

    This is link to file where i initialized script http://hafizovic.ba/wp/wp-content/themes/hafizovic/js/custom.js?ver=05012016

    opened by hafizovic 3
  • mount, unmount function for react component list

    mount, unmount function for react component list

    Hi ademilter. Thanks your code.

    I used your bricklayer at react code. But occur some issue.

    If react component draw in list item with Ajax call more then One, occur some issue(do not run React-Router Link, Redux).

    I added some function for react component list.

    Use next example at Ajax success function callback.

    this.bricklayer.unmount();
    self.setState({items:self.state.items.concat(items));
    this.bricklayer.mount();
    

    See my code example

    import React from 'react';
    import { connect } from 'react-redux';
    import { render, findDOMNode } from 'react-dom';
    import { browserHistory, Router, Route, Link, withRouter } from 'react-router';
    
    import Messages from './Messages';
    import PostSummary from './PostSummary';
    
    export function postSummary(props, post) {
        return <PostSummary {...props} post={post}/>;
    }
    
    class Home extends React.Component {
        constructor(props) {
            super(props);
            this.state = {
                posts : []
            };
        }
    
        loadSummary() {
            let self = this;
            let count = 10;
            let userId = 'all';
            if(this.props.params.id != undefined) {
                userId = this.props.params.id;
            }
            let url = `/post/list/${userId}/${this.lastPostId}/${count}`;
            this.listProgress = true;
            this.serverRequest = $.ajax({
                url: url,
                method: 'GET',
                dataType: 'json',
                cache: false,
                success: function(posts) {
                    posts.forEach(function(post) {
                        self.lastPostId = post.id;
                    });
                    let scroll = {x:window.scrollX, y:window.scrollY};
                    this.bricklayer.unmount();
                    self.setState({posts:self.state.posts.concat(posts.concat())});
                    this.bricklayer.mount();
                    window.scrollTo(scroll.x, scroll.y);
                    if(count > posts.length) {
                        clearInterval(self._timer);
                    }
                    self.listProgress = false;
                }.bind(this),
                error: function(xhr, status, err) {
                    console.error(url, status, err.toString());
                    self.listProgress = false;
                }
            });
        }
    
        componentDidMount() {
            this.bricklayer = new Bricklayer(document.querySelector('.bricklayer'));
    
            this.lastPostId = "recent";
            this.listProgress = false;
            this.loadSummary();
    
            let self = this;
            this._timer = setInterval(function() {
                if(self.listProgress) {
                    return;
                }
                let brick = $(".bricklayer");
                let brickBottom = brick.offset().top + brick.height();
                let brickBottomOffset = brickBottom - $(window).height() - $(window).scrollTop();
                let offset = 400;
                if(brickBottomOffset < offset) {
                    self.loadSummary();
                }
            }, 500);
        }
    
        componentWillUnmount() {
            this.bricklayer.destroy();
            this.serverRequest.abort();
            this.listProgress = false;
    
            clearInterval(this._timer);
        }
    
        render() {
            const summary = this.state.posts.map(function(post) {
                return (<PostSummary key={post.id} post={post}/>);
            });
            return (
                <div className="container">
                    <Messages messages={this.props.messages}/>
                    <div className="bricklayer">
                        {summary}
                    </div>
                </div>
            );
        }
    }
    
    const mapStateToProps = (state) => {
        return {
            messages: state.messages
        };
    };
    
    export default connect(mapStateToProps)(Home);
    
    
    opened by devmario 2
  • adjusting width of single box

    adjusting width of single box

    I just discovered bricklayer and i am happy who it works.

    I was just wondering is it possible to make certain boxes wider? e.g. standard box and also column is for example 25% but i want certain boxes be like 50% while the rest goes around it. So not that the whole column is 50% width.

    Thanks in advance

    opened by greenlevel 1
  • bricklayer.destroy()

    bricklayer.destroy()

    Trying to use Bricklayer.js in multiple IDs in same page. Or even it will be helpful to know, how to bricklayer all .bricklayer classes.

    Any proper way to use bricklayer.destroy(); ? Is there any good example?

    I tried: bricklayer.destroy(); var bricklayer = new Bricklayer(document.getElementById('bricklayer'));

    The code throws error Uncaught TypeError: Cannot read property 'destroy' of undefined

    opened by shohagbhuiyan 1
  • When lots of columns detected, it confusing about min columns without items.

    When lots of columns detected, it confusing about min columns without items.

    In wall example, if there are lots of columns appear, it fails with finding min height column when all columns are empty. It finds it when at least one element exists.

    bug enhancement 
    opened by f 1
  • Remove jQuery dependency.

    Remove jQuery dependency.

    Since jQuery is not much used, we can remove jQuery and make the plugin vanilla.

    Used jQuery helpers:

    • #width(), #height()
    • #isArray()
    • #append()
    • #prepend()
    • #on("resize", fn)
    • #not(..)
    • #find(..)
    • #trigger()
    enhancement 
    opened by f 1
  • IE Fix: Add type check for CustomEvent property

    IE Fix: Add type check for CustomEvent property

    Added a type check for the window.CustomEvent property to check it is actually a function. IE returns window.CustomEvent as an object, so a new instance cannot be created.

    opened by rdunk 0
  • Distance between columns

    Distance between columns

    Hi folks, any suggestions on how to set the distance between columns? I'm playing with Padding and Margin customizing the CSS but the results are horrifying.

    opened by LorenzoPinto04 1
  • We use bricklayer, too!

    We use bricklayer, too!

    Please add this to the list!

    Website: metis.eecs.wsu.edu Title: Pathways College Finder

    This is a senior design project that will be used by the company SCALE. The server provided will go down in June, but sometime later the app will be redeployed elsewhere. When more colleges are added to our database, the true benefits of bricklayer can be seen. After hours of playing with bootstrap card columns and decks, bricklayer was the easy choice and huge time saver.

    opened by MatthewJJohnson 0
  • content 'flash' in Chrome...

    content 'flash' in Chrome...

    Hello — bricklayer working OK in this preview site :: https://gresfordarchitects.co.uk/projects

    But Chrome is giving a strange 'flash' of a large content item each time the page is accessed... (try clicking the 'project' button several times... this issue seems specific to Chrome...

    Any clues as to what this might be?!

    thanks

    opened by MattAppleton 0
  • element removal with remaining elements filling in the gaps

    element removal with remaining elements filling in the gaps

    for certain scenarios, besides append and prepend, one may want to remove an element and all the other elements to redraw to fill in the gaps...

    enhanced the demo as well with remove on click

    opened by dandohotaru 3
  • We use bricklayer, too!

    We use bricklayer, too!

    Please add this to the list!

    Website: http://www.bether.me Title: Angular 2+ with gridLayer

    Thank you very much for your esfort in that library First I was testing bootstrap cards-columns but it was incredible that they have horizontal order. Your library save tons of hours in work

    opened by empresarioMadri 0
Owner
Adem ilter
crafting interfaces
Adem ilter
The Raspberry Pi + OpenScan Pi Shield can be used to control two independent stepper motors and a variety of different cameras

OpenScan2 Overview: The Raspberry Pi + OpenScan Pi Shield can be used to control two independent stepper motors and a variety of different cameras (Pi

Thomas 149 Jan 3, 2023
JavaScript image gallery for mobile and desktop, modular, framework independent

PhotoSwipe v5 — JavaScript image gallery and lightbox Demo | Documentation Repo structure dist/ - main JS and CSS src/ - source JS and CSS. src/js/pho

Dmytro Semenov 22.4k Dec 29, 2022
Create a card layout that let your user flip through it like you see on Google Tips

#Tip Cards by Pete R. Create an animated card layout that let your viewer flip through it like you see on Google Tips Page. Created by Pete R., Founde

Pete R. 213 Nov 5, 2022
A simple library to draw option menu or other popup inputs and layout on Node.js console.

console-gui-tools A simple library to draw option menu or other popup inputs and layout on Node.js console. console-gui-tools A simple Node.js library

Elia Lazzari 12 Dec 24, 2022
Simple, responsive and lightweight Masonry Grid jQuery Plugin.

jquery-masonry-grid Simple, responsive and lightweight Masonry Grid jQuery Plugin. Installation Add the script before closing the <body> tag (make sur

Peter Breitzler 8 Jun 9, 2022
Minimalist dependancy free Masonry layout library

MiniMasonry.js Minimalist dependency free Masonry layout library MiniMasonry is a lightweight dependency free Masonry layout. It will compute elements

Spope 343 Dec 4, 2022
A work-in-progress HTML sanitizer that strives for: performance like window.Sanitizer, readiness like DOMPurify, and ability to run in a WebWorker like neither of those.

Amuchina A work-in-progress HTML sanitizer that strives for: performance like window.Sanitizer, readiness like DOMPurify, and ability to run in a WebW

Fabio Spampinato 9 Sep 17, 2022
2D HTML5 rendering and layout engine for game development

Stage.js is a 2D HTML5 JavaScript library for cross-platform game development, it is lightweight, fast and open-source. Check out examples and demos!

Ali Shakiba 2.2k Jan 3, 2023
Script para crear un layout tipo masonry.

light-masonry Script para crear un layout tipo masonry. Solo es necesario tener el contenedor junto a sus hijos que se acomodaran en este tipo de layo

Lenin Felix 2 Feb 4, 2022
Use jsx to make scriptable's layout.

scriptable-jsx This project helps you to write Scriptable widgets with JSX syntax. And add some useful tools by the way. you can check demos in demo f

毛球 8 Oct 10, 2022
Chrome & Firefox extension to return old Twitter layout from 2015.

OldTwitter (2022) Chrome extension to return old Twitter layout from 2015. This extension doesn't add any CSS on top of original Twitter. It's fully o

dimden 35 Jan 4, 2023
Print seat layout for movie, flight (jQuery plugin)

seatLayout.js (movie-seat-layout) Print seat layout for movie, flight and seat selection (jQuery plugin) Demo : https://sachinkurkute.github.io/movie-

Sachin Kurkute 20 Dec 8, 2022
Freewall is a cross-browser and responsive jQuery plugin to help you create grid, image and masonry layouts for desktop, mobile, and tablet...

Freewall Freewall is a cross-browser and responsive jQuery plugin to help you create many types of grid layouts: flexible layouts, images layouts, nes

Minh Nguyen 1.9k Dec 27, 2022
This is a Tic Tac Toe game built with HTML, CSS, and JavaScript. It is a simple and fun game where two players take turns marking X and O on a 3x3 grid.

Tic Tac Toe Game This is a Tic Tac Toe game built with HTML, CSS, and JavaScript. It is a simple and fun game where two players take turns marking X a

Andrew Tsegaye 4 Mar 4, 2023
Minimalistic portfolio/photography site with masonry grid, page transitions and big images.

Gatsby Starter Portfolio: Emilia Minimalistic portfolio/photography site with masonry grid, page transitions and big images. Themeable with Theme UI.

Cryptob3auty 1 May 20, 2022
Fancytree - JavaScript tree view / tree grid plugin with support for keyboard, inline editing, filtering, checkboxes, drag'n'drop, and lazy loading

Fancytree Fancytree (sequel of DynaTree 1.x) is a JavaScript tree view / tree grid plugin with support for keyboard, inline editing, filtering, checkb

Martin Wendt 2.6k Jan 9, 2023
Backgrid.js is a set of components for building semantic and easily stylable data grid widgets

Backgrid.js is a set of components for building semantic and easily stylable data grid widgets. It offers a simple, intuitive programming interface that makes easy things easy, but hard things possible when dealing with tabular data.

Cloudflare Archive 2k Nov 21, 2022
Página da Web que tem uma calculadora simples utilizando CSS Grid, JavaScript e HTML

Calculadora-Oline Calculadora exibida online via HTML e CSS, com foco no CSS Grid. Utilizei quatro (sub)grids dentro de uma principal, a qual engloba

João Vitor Esposte Campos 3 Nov 21, 2022
An npm package with Tailwind CSS utility classes for creating responsive grid columns without media queries using auto fit.

Grid Auto Fit for Tailwind CSS A plugin that helps you create a responsive grid layout in Tailwind CSS without using media queries. It uses the auto-f

Thirus 80 Dec 28, 2022