All Projects → nekobird → Stack Up.js

nekobird / Stack Up.js

Licence: mit
Create fixed width, variable height grid layouts.

Programming Languages

coffeescript
4710 projects

Projects that are alternatives of or similar to Stack Up.js

Waterfall.js
Tired of use creepy hacks or heavy ways to get a Grid based on Pinterest?
Stars: ✭ 458 (+291.45%)
Mutual labels:  layout, grid
Collectionviewpaginglayout
a simple but highly customizable paging layout for UICollectionView.
Stars: ✭ 947 (+709.4%)
Mutual labels:  stack, layout
Svelte Grid
A responsive, draggable and resizable grid layout, for Svelte.
Stars: ✭ 473 (+304.27%)
Mutual labels:  layout, grid
Flutter Layouts Exampls
Layout of the flutter example.such as Row,Comlun,listview,Just for learning.
Stars: ✭ 292 (+149.57%)
Mutual labels:  stack, layout
Aceto
A programming language based on a 2D Hilbert curve grid
Stars: ✭ 83 (-29.06%)
Mutual labels:  stack, grid
Tinyconstraints
Nothing but sugar.
Stars: ✭ 3,721 (+3080.34%)
Mutual labels:  stack, layout
Egjs Infinitegrid
A module used to arrange card elements including content infinitely on a grid layout.
Stars: ✭ 751 (+541.88%)
Mutual labels:  layout, grid
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 (-85.47%)
Mutual labels:  grid, layout
Interior
Design system for the modern web.
Stars: ✭ 77 (-34.19%)
Mutual labels:  layout, grid
Easygrid
EasyGrid - VanillaJS Responsive Grid
Stars: ✭ 77 (-34.19%)
Mutual labels:  layout, grid
React Flexview
A powerful React component to abstract over flexbox and create any layout on any browser
Stars: ✭ 276 (+135.9%)
Mutual labels:  layout, grid
React Photo Layout Editor
Photo layout editor for react
Stars: ✭ 96 (-17.95%)
Mutual labels:  layout, grid
gymnast
🤸 Configurable grid and layout engine for React
Stars: ✭ 35 (-70.09%)
Mutual labels:  grid, layout
React Native Responsive Grid
Bringing the Web's Responsive Design to React Native
Stars: ✭ 369 (+215.38%)
Mutual labels:  layout, grid
vue-smart-widget
🗃️Smart widget is a flexible and extensible content container component for Vue2.x / Vue3.x in Next branch.
Stars: ✭ 110 (-5.98%)
Mutual labels:  grid, layout
Flex Layout
Provides HTML UI layout for Angular applications; using Flexbox and a Responsive API
Stars: ✭ 5,705 (+4776.07%)
Mutual labels:  layout, grid
CSS-Grid
CSS Grid 레이아웃 모듈 Level 1
Stars: ✭ 21 (-82.05%)
Mutual labels:  grid, layout
grid-layout
grid-layout is a layout engine which implements grid, can use in canvas/node-canvas
Stars: ✭ 43 (-63.25%)
Mutual labels:  grid, layout
Masonry Layout
An efficient and fast web component that gives you a beautiful masonry layout
Stars: ✭ 43 (-63.25%)
Mutual labels:  layout, grid
React Native Flexbox Grid
Responsive Grid for React Native
Stars: ✭ 95 (-18.8%)
Mutual labels:  layout, grid

stack-up.js

A simple and fast JavaScript plugin to help you create fixed-width, variable-height grid layout.

Getting started

First, include stack-up.js to your project.

<!-- Example HTML -->
<div id="gridContainer">
  <div class="gridItem">...</div>
  <div class="gridItem">...</div>
  <div class="gridItem">...</div>
</div>

<!-- Scripts -->
<script src="js/stack-up.js"></script>

Minimum CSS requirements

#gridContainer {
  position: relative;
}

.gridItem {
  position: absolute;
}

.gridItem img {
  width: 100%;
}

Make sure all content inside the container are loaded before initializing stack-up. This is to make sure stack-up calculates the right height before plotting.

// One way to make sure everything is loaded is
// to wrap the initializer inside window onload.
window.onload = function() {

  // Create a stackup object.
  var stackup = new StackUp({
    containerSelector: "#gridContainer",
    itemsSelector    : "#gridContainer > .gridItem",
    columnWidth      : 240,
  });
  // Initialize stackup.
  stackup.initialize();

};

Config

Customize stack-up to your needs.

stackup.setConfig({
  columnWidth        : 320,
  gutter             : 18,
  isFluid            : false,
  layout             : "ordinal", // ordinal, optimized
  numberOfColumns    : 3,
  resizeDebounceDelay: 350
});

// This function allows you to modify how each item is moved or animated.
stackup.config.moveItem: function(item, left, top, callback) {
  item.style.left = left + "px";
  item.style.top  = top + "px";
  // The callback function is required to continue operation.
  callback();
};

// This one allows you to modify how the container scales.
stackup.config.scaleContainer: function(container, width, height, callback) {
  container.style.width  = width + "px";
  container.style.height = height + "px";
  // The callback function is required to continue operation.
  callback();
};

Reset and restack

Once the grid is initialized; you will need to call the restack method if you change any of the configurations.

stackup.config.layout = 'optimized';
stackup.restack();

The restack method will not work properly if you change something that affect the dimensions of the grid item. You will have to use reset instead. (This recalculates the grid stacking from top to bottom.)

stackup.config.columnWidth = 220;
stackup.reset();

You will also need to use the reset method if you add or remove any grid item.

Append

The append method allows you to add a new grid item without re-calculating everything.

// Get container element.
var gridContainer = document.getElementById("gridContainer");

// Create a new grid item element.
var gridItem = document.createElement("div");
gridItem.setAttribute("class", "gridItem");
gridItem.innerHTML = "blah blah";

// Append the new grid item element into container element.
gridContainer.appendChild(gridItem);

// Append it to stackup.
stackup.append(gridItem);

There is currently no prepend method.

That's it!

License

StackUp is licensed under the MIT license - http://opensource.org/licenses/MIT

Copyright (C) 2017 Andrew Prasetya

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