Script para crear un layout tipo masonry.

Overview

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 layout.

El script formateara todo, agregara y colocara lo necesario para que funcione el layout.

npm npm bundle size

Demo

Codepen

CSS

  • Este script necesita algunos styles base:

    /* ------------------ light-masonry.css ------------------ */
    .light-masonry-wrapper {
      --gap: 5px;
      --gap-between-columns: var(--gap);
      --gap-between-items: var(--gap);
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
      width: 100%;
      grid-gap: var(--gap-between-columns);
    }
    
    .light-masonry-column {
      display: flex;
      flex-direction: column;
      justify-content: flex-start;
      align-items: center;
      width: 100%;
    }
    
    .light-masonry-column .light-masonry-item {
      width: 100%;
    }
    
    .light-masonry-column .light-masonry-item:not(:last-child) {
      margin-bottom: var(--gap-between-items);
    }

    Aquí hay 3 variables css que podemos manipular:

    • —gap El valor de este cambia los espacios tanto entre las filas y las columnas, totalmente parejo.
    • —gap-between-columns El valor de este cambia solo los espacios entre cada columna. Eje horizontal
    • —gap-between-items El valor de este cambia solo los espacios entre cada item. Eje vertical NOTA: Estas variables van en la misma clase que le pasaste al script.

Parámentros

  • containerClass [Required] [String] Este parametro recibe la clase del contenedor al que se configurara el script.
    const container = ".main-container-masonry";
  • Options [Optional] [Object] Él parámetro que recibe es un objeto con todas las opciones posibles. Cada que agregues una option esta se actualizara la default.
    const options = {
      defaultColumns: 4,
      responsive: {
        1440: 4,
        834: 3,
        680: 2,
      },
      init: (data) => {},
      afterBreakpoint: (data) => {},
    };
    • defaultColumns [Optional] [Number] Este campo sirve para colocar las columnas por default que tendrá el layout dado caso no se pasen medidas responsive o si las medidas responsive dadas ya no se se cumplen
      const options = {
        defaultColumns: 5,
      };
    • responsive [Optional] [Object] Este parámetro sirve para agregar las medidas responsive y las columnas que abra en cada query. Se basa en desktopFirst, es decir, una vez que alcanza la medida este se configura hacia abajo, dando el numero de columnas pasado a esta medida, y cambia una vez alcance la siguiente medida.
      const options = {
        responsive: {
          // window.width <= 1440px : 4 columns
          1440: 4,
          // window.width <= 834px : 3 columns
          834: 3,
          // window.width <= 680px : 2 columns
          680: 2,
        },
      };
    • init [Optional] [function] Retorna el objeto con la información actualmente en ejecución. Se lanza justo después de configurar el script por primera vez.
      const options = {
        init: (data) => {
          console.log(data);
        },
      };
    • afterBreakpoint [Optional] [function] Retorna el objeto con la información actualmente en ejecución. Se lanza justo después de cada cambio de breakpoint.
      const options = {
        afterBreakpoint: (data) => {
          console.log(data);
        },
      };
You might also like...

Script to synchronize between a Notion database and Google Calendar both ways. Uses Google App Script.

Yet Another Two Way Notion-Google Calendar Sync Script A script to sync events between Google calendar and a Notion database. Features! Google App Scr

Jan 7, 2023

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

Nov 5, 2022

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

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

Dec 24, 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

Oct 10, 2022

Lightweight and independent Pinterest-like cascading grid layout library

Lightweight and independent Pinterest-like cascading grid layout library

Bricklayer is a Lightweight and Independent Pinterest-like Cascading Grid Layout Library 💎 Simpler than any other cascading grid layout tools. ❄️ Lig

Dec 22, 2022

Chrome & Firefox extension to return old Twitter layout from 2015.

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

Jan 4, 2023

2D HTML5 rendering and layout engine for game development

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!

Jan 3, 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-

Dec 8, 2022

Script para colocar la altura maxima entre el conjunto de elementos.

set-height-elements Script para colocar la altura maxima entre el conjunto de elementos. La principal función de este script es hacer que todos los el

Feb 4, 2022
Comments
  • Aplicar una function debounce

    Aplicar una function debounce

    https://github.com/soyleninjs/light-masonry/blob/b0a1d0896b2365a5b112b6bcde6cf3e0559261d5/js/light-masonry.js#L204

    Recomendaria aplicar una function debounce en el resize.. para que asi no se aplique exactamente en cada pixel que se recorrio en el resize.... si no que solo al finaaal fianlisimo de que terminaste de hacer resize, esto aligera mucho el computo a realizar

    opened by Jorge-Mauricio-Rodriguez 1
  • Si no existe el nodo da error

    Si no existe el nodo da error

    https://github.com/soyleninjs/light-masonry/blob/b0a1d0896b2365a5b112b6bcde6cf3e0559261d5/js/light-masonry.js#L16

    Se podria poner una comprobación para que compruebe la existencia del nodo, en caso de que no exista, no hacer mada

    opened by Jorge-Mauricio-Rodriguez 1
Releases(v1.0.4)
Owner
Lenin Felix
Frontend Developer / Shopify Themes Developer - Sigueme en mis Redes Sociales como @soyleninjs
Lenin Felix
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
Um website completo desenvolvido com Next SSR, Typescript, Prismic CMS do tipo blog com diversas funcionalidades para interações entre os usuários.

Título: Spacetraveling Descrição: Um website completo desenvolvido com Next SSR, Typescript, Prismic CMS do tipo blog com diversas funcionalidades par

Guilherme Augusto de Almeida Amaral 8 Dec 21, 2022
Chontaduro, Borojo, Sancocho de gallina y algo sustancia perico fueron usadas para crear el mejor proyecto de código en toda la historia de Colombia

Chontaduro, Borojo, Sancocho de gallina y algo sustancia perico fueron usadas para crear el mejor proyecto de código en toda la historia de Colombia

juansito 6 May 11, 2022
Sencillisima colección de repositorios de cualquier tipo de cursada en FIUBA (TPs/Parciales/Finales/etc)

FIUBA Repos Sencillisima colección de repositorios de cualquier tipo de cursada en FIUBA (TPs/Parciales/Finales/etc) La idea de este proyecto es tener

Federico del Mazo 12 Oct 5, 2022
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
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
A javascript plugin to filter elements from a "masonry" grid.

Isolde Isolde is a lightweight, flexible, and responsive javascript plugin allow you to filter elements from a "masonry" grid. Quick start Install Thi

Tristan BOULANGER 24 Oct 13, 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
Customizable masonry Flatlist. it just behave like Flatlist but using ScrollView behind the scene

Would you like to support me? react-native-masonry-grid Customizable masonry Flatlist. it just behave like Flatlist but using ScrollView behind the sc

Numan 5 Sep 7, 2022
Script to fetch all NFT owners using moralis API. This script output is a data.txt file containing all owner addresses of a given NFT and their balances.

?? Moralis NFT Snapshot Moralis NFT API will only return 500 itens at a time when its is called. For that reason, a simple logic is needed to fetch al

Phill Menezes 6 Jun 23, 2022