All Projects → andreasbm → Masonry Layout

andreasbm / Masonry Layout

Licence: mit
An efficient and fast web component that gives you a beautiful masonry layout

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Masonry Layout

egjs-grid
A component that can arrange items according to the type of grids
Stars: ✭ 188 (+337.21%)
Mutual labels:  grid, layout, masonry
The Grid
Grid layout custom element with drag and drop capabilities
Stars: ✭ 122 (+183.72%)
Mutual labels:  layout, grid, webcomponents
masonry-css
Create mosaic grid, like masonry, with css only
Stars: ✭ 17 (-60.47%)
Mutual labels:  grid, layout, masonry
Shuffle
Categorize, sort, and filter a responsive grid of items
Stars: ✭ 2,170 (+4946.51%)
Mutual labels:  layout, grid, masonry
Egjs Infinitegrid
A module used to arrange card elements including content infinitely on a grid layout.
Stars: ✭ 751 (+1646.51%)
Mutual labels:  layout, grid, masonry
svelte-bricks
Naive Svelte Masonry component without column balancing (ragged columns at the bottom)
Stars: ✭ 22 (-48.84%)
Mutual labels:  layout, masonry
visual-portfolio
Portfolio layouts visual editor with Gutenberg support
Stars: ✭ 31 (-27.91%)
Mutual labels:  grid, masonry
Fluid-Grid
Fluid, Responsive and Semantic grid for Sass (SCSS) or LESS CSS. Supports any number of columns. Gutter width is defined as percentage, and grids can be nested too.
Stars: ✭ 17 (-60.47%)
Mutual labels:  grid, layout
gymnast
🤸 Configurable grid and layout engine for React
Stars: ✭ 35 (-18.6%)
Mutual labels:  grid, layout
vue-layout-system
A pack of Vue components that solve daily layout problems
Stars: ✭ 31 (-27.91%)
Mutual labels:  grid, layout
cwco
Powerful and Fast Web Component Library with a Simple API
Stars: ✭ 27 (-37.21%)
Mutual labels:  webcomponents, vanilla-js
React Flexview
A powerful React component to abstract over flexbox and create any layout on any browser
Stars: ✭ 276 (+541.86%)
Mutual labels:  layout, grid
CSS-Grid
CSS Grid 레이아웃 모듈 Level 1
Stars: ✭ 21 (-51.16%)
Mutual labels:  grid, layout
angular-bricklayer
AngularJS module for ademilter's bricklayer, a lightweight & independent cascading grid layout library
Stars: ✭ 42 (-2.33%)
Mutual labels:  grid, layout
grid-layout
grid-layout is a layout engine which implements grid, can use in canvas/node-canvas
Stars: ✭ 43 (+0%)
Mutual labels:  grid, layout
bootstrap-grid-ms
Missing grid range in Bootstrap 3, micro-small from 480-767px.
Stars: ✭ 34 (-20.93%)
Mutual labels:  grid, layout
vue-smart-widget
🗃️Smart widget is a flexible and extensible content container component for Vue2.x / Vue3.x in Next branch.
Stars: ✭ 110 (+155.81%)
Mutual labels:  grid, layout
Svelte Grid
A responsive, draggable and resizable grid layout, for Svelte.
Stars: ✭ 473 (+1000%)
Mutual labels:  layout, grid
Waterfall.js
Tired of use creepy hacks or heavy ways to get a Grid based on Pinterest?
Stars: ✭ 458 (+965.12%)
Mutual labels:  layout, grid
Vue Masonry
💠 Vue.js directive for masonry blocks layouting ✅
Stars: ✭ 509 (+1083.72%)
Mutual labels:  layout, masonry

@appnest/masonry-layout

Downloads per month NPM Version Dependencies Contributors Published on webcomponents.org

An efficient and fast web component that gives you a beautiful masonry layout Go here to see a demo https://appnest-demo.firebaseapp.com/masonry-layout.


  • Simple: Works right out of the box (just add it to your markup)
  • Lightweight: Super small (1kb minified & gzipped)
  • Zero dependencies: Created using only vanilla js - no dependencies and framework agnostic!
  • Customizable: Can customize almost everything (eg. columns, transitions, gap).
  • User friendly: Automatically re-distribute items when the size of the grid changes or new elements are added
  • Performant: Efficient & fast - Build with performance in mind

-----------------------------------------------------

➤ Installation

npm i @appnest/masonry-layout

If you prefer to use umd bundle you can load https://unpkg.com/@appnest/masonry-layout/umd/masonry-layout.min.js instead.

-----------------------------------------------------

➤ Example

Import @appnest/masonry-layout somewhere in your code and you're ready to go! Simply add the masonry-layout element to your html and then add your elements in between the start and closing tags.

<masonry-layout>
  <div>1</div>
  <div>2</div>
  <div>3</div>
  <div>4</div>
  <div>5</div>
</masonry-layout>

-----------------------------------------------------

➤ Customize

Customize the functionality by applying the attributes.

Amount of columns

The cols attribute specifies the amount of columns. The default value is auto which ensures to distribute the elements based on the available width.

<masonry-layout cols="5">
  ...
</masonry-layout>

Gap between columns and rows

The gap attribute specifies how many pixels the gap between the elements should be. The default value is 24px.

<masonry-layout gap="50">
  ...
</masonry-layout>

Max column width

The maxcolwidth specifies how many pixels a column can maximum have when the cols attribute is set to auto. The default value is 400px.

<masonry-layout maxcolwidth="200">
  ...
</masonry-layout>

Change debounce time

The debounce attribute specifies the amount of time in ms the layout reflow debounces each time the size of the masonry layout changes. This reflow is debounced to avoid the layout algorithm being invoked too many times in a row. The default value is 300ms.

<masonry-layout debounce="500">
  ...
</masonry-layout>

-----------------------------------------------------

➤ Trigger layout

If you want to force layout to can call the layout() function on the masonry layout.

document.querySelector("masonry-layout").layout();

If you wish to debounce the layout you can call the scheduleLayout() function instead.

document.querySelector("masonry-layout").scheduleLayout();

-----------------------------------------------------

➤ Overview

Here's a complete overview of the element.

masonry-layout

Masonry layout web component. It places the slotted elements in the optimal position based on the available vertical space, just like mason fitting stones in a wall.

Example

<masonry-layout><div class="item"></div><div class="item"></div></masonry-layout>

Properties

Property Attribute Type Description
cols cols number | "auto" The amount of columns.
debounce debounce number The ms of debounce when the element resizes.
gap gap number The gap in pixels between the columns.
layout
maxColWidth maxcolwidth number The maximum width of each column if cols are set to auto.
onResize
onSlotChange

Methods

Method Type Description
layout (): void Layouts the elements.
onResize (entries?: object | undefined): void Each time the element resizes we need to schedule a layout
if the amount available columns has has changed.
onSlotChange (): void
renderCols (colCount: number): void Render X amount of columns.
scheduleLayout (ms?: number): void Schedules a layout.

Slots

Name Description
Items that should be distributed in the layout.

CSS Shadow Parts

Part Description
column Each column of the masonry layout.
column-index The specific column at the given index (eg. column-0 would target the first column and so on)

-----------------------------------------------------

➤ Support for old browsers

If you are going to support older browsers that doesn't support Custom Elements, Shadow Dom or ResizeObservers you should polyfill the features. You can do this very easily by using the brilliant polfiller service. This can be done in one line of code by adding the following to your index.html before you import the masonry-layout.

<script crossorigin src="https://polyfill.app/api/polyfill?features=es,template,shadow-dom,custom-elements,resizeobserver"></script>

-----------------------------------------------------

➤ License

Licensed under MIT.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].