Responsive, Draggable, Filterable Grid Layout – muuri

Category: Javascript , Layout , Recommended | September 27, 2018
Author: haltu
Views Total: 3,942
Official Page: Go to website
Last Update: September 27, 2018
License: MIT

Preview:

Responsive, Draggable, Filterable Grid Layout – muuri

Description:

muuri is a versatile JavaScript library which helps you create responsive, draggable, filterable, searchable grid layout with smooth animations based on Velocity.js.

Install it via package managers:

# Yarn
yarn add muuri

# NPM
$ npm install muuri

# Bower
$ bower install muuri

Basic usage:

Include the main JavaScript file ‘muuri.js’ on the webpage.

<script src="muuri.min.js"></script>

Include the hammer.js for the support of touch gestures.

<script src="/path/to/hammer.min.js"></script>

Include the Velocity.js for the smooth animations while dragging and filtering.

<script src="/path/to/velocity.min.js"></script>

Add your own grid items to the layout.

<div class="grid">

  <div class="item">
    <div class="item-content">
      Item 1
    </div>
  </div>

  <div class="item">
    <div class="item-content">
      Item 2
    </div>
  </div>

  <div class="item">
    <div class="item-content">
      Item 3
    </div>
  </div>

  ...

</div>

Initialize the grid layout:

var grid = new Muuri('.grid');

Apply your own CSS styles to the layout & grid items:

.grid { position: relative; }

.item {
  display: block;
  position: absolute;
  width: 100px;
  height: 100px;
  margin: 5px;
  z-index: 1;
}

.item.muuri-dragging, .item.muuri-releasing { z-index: 2; }

.item.muuri-hidden { z-index: 0; }

.item-content {
  position: relative;
  width: 100%;
  height: 100%;
}

Config the grid layout with the following options.

var grid = new Muuri('.grid',{
    // Item elements
    items: '*',

    // Default show animation
    showDuration: 300,
    showEasing: 'ease',

    // Default hide animation
    hideDuration: 300,
    hideEasing: 'ease',

    // Item's visible/hidden state styles
    visibleStyles: {
      opacity: '1',
      transform: 'scale(1)'
    },
    hiddenStyles: {
      opacity: '0',
      transform: 'scale(0.5)'
    },

    // Layout
    layout: {
      fillGaps: false,
      horizontal: false,
      alignRight: false,
      alignBottom: false,
      rounding: true
    },
    layoutOnResize: 100,
    layoutOnInit: true,
    layoutDuration: 300,
    layoutEasing: 'ease',

    // Sorting
    sortData: null,

    // Drag & Drop
    dragEnabled: false,
    dragContainer: null,
    dragStartPredicate: {
      distance: 0,
      delay: 0,
      handle: false
    },
    dragAxis: null,
    dragSort: true,
    dragSortInterval: 100,
    dragSortPredicate: {
      threshold: 50,
      action: 'move'
    },
    dragReleaseDuration: 300,
    dragReleaseEasing: 'ease',
    dragHammerSettings: {
      touchAction: 'none'
    },

    // Classnames
    containerClass: 'muuri',
    itemClass: 'muuri-item',
    itemVisibleClass: 'muuri-item-shown',
    itemHiddenClass: 'muuri-item-hidden',
    itemPositioningClass: 'muuri-item-positioning',
    itemDraggingClass: 'muuri-item-dragging',
    itemReleasingClass: 'muuri-item-releasing'
});

Changelog:

v0.7.0 (09/27/2018)

  • Bugfix

You Might Be Interested In:


Leave a Reply