• This repository has been archived on 05/Jan/2022
  • Stars
    star
    1,230
  • Rank 38,157 (Top 0.8 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 12 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Mason.js for creating a perfect grid with jQuery.

forthebadge

MasonJS

Mason.js is a jQuery plugin that allows you to create a perfect grid of elements.

This is not Masonry, or Isotope or Gridalicious. Mason fills in those ugly gaps, and creates a perfectly filled space.

Bower Version

2.0.2

USE

Basic CSS

#container {
	width: 100%;
	position: relative;
}
.box {
	float: left;
	background-color: #00ffff;
	position: relative;
}

Call Mason.js (BASIC)

$("#container").mason({
	itemSelector: ".box",
	ratio: 1.5,
	sizes: [
		[1,1],
		[1,2],
		[2,2]
	]
});

OPTIONS

Mason.js has a number of options:

$("#container").mason({
	itemSelector: ".box",
	ratio: 1.5,
	sizes: [
		[1,1],
		[1,2],
		[2,2]
	],
	columns: [
		[0,480,1],
		[480,780,2],
		[780,1080,3],
		[1080,1320,4],
		[1320,1680,5]
	],
	promoted: [
		['class_name', 2, 1],
		['class_name', 2, 3],
		['class_name', 3, 3],
	],
	filler: {
		itemSelector: '.fillerBox',
		filler_class: 'custom_filler',
		keepDataAndEvents: false
	},
	layout: 'fluid',
	gutter: 10
},function(){
	console.log("COMPLETE!")
});
  • itemSelector
    • the element that makes up your grid
  • ratio
    • The ratio is a number that is used to create the blocks based on column count and width. This is based on the number of columns requested and the browser width.
  • sizes
    • Sizes are an array of sizes you wish to use in your grid. These are composed of block numbers. (ex: [1,1] means 1 block high, 1 block wide)
  • columns
    • columns are an array of break points for your columns. Think of this like media queries. start small and grow. They should be formatted as [min,max,cols]
  • filler
    • itemSelector: This describes the elements to be used to fill in blank spaces. This will default to the original itemSelector if there is nothing
    • filler_class: This is a class given to filler elements within the grid, used for cleaning up if a grid set to fluid
    • keepDataAndEvents: Mason creates a clone of the filler elements before adding them to the grid, this boolean (true/false) property tells Mason to retain the events and data that have already been bound to the filler elements
  • promoted
    • Accepts an array of ['CLASS_NAME', WIDTH, HEIGHT] these items will be forced to those dimensions.
  • Layout
    • There are two layouts, fluid and fixed. Mason will default to fixed. Fluid means it will be responsive.
  • Callback
    • You can add a callback function to Mason to notify you when the grid has completed building.
  • Gutter
    • Allows you to add spacing between the elements, think of this as a margin.

DESTROY

At times you may want to destroy the mason object and no longer track window changes, to do this assign the mason grid to a variable such as var mason and when you're ready to destroy just call mason.destroy() this will remove all listeners on the mason object and you can remove the grid or elements without any ill effects.

Install

  1. npm install
  2. bower install

Running

cd into project and run gulp

Building

cd into project

  1. run gulp dist
  2. run gulp finish_dist

Examples

Look at the public folder for examples.

More Repositories

1

Phonegap-LocalNotification

An example of how to use the LocalNotification plugin for Phonegap
JavaScript
86
star
2

dockerize-all-the-things

Make your life easier by using containers for everything.
PHP
84
star
3

headless-wordpress

A headless CMS for publishing static JSON for consumption.
PHP
83
star
4

wp-headless

A simple plugin for publishing static JSON files from Wordpress for a headless CMS.
PHP
77
star
5

ImageFilter

A phonegap plugin for creating instagram style filters for photos.
JavaScript
62
star
6

phonegapFacebookApp

JavaScript
33
star
7

vagrant-puppet-boilerplate

Vagrant + Puppet + Rails + Nginx + Unicorn = awesome sauce
Ruby
16
star
8

phoneGapTwitterApp

A way to create a twitter app with phonegap
JavaScript
15
star
9

Pinned

A jQuery plugin for creating sticky elements
JavaScript
14
star
10

Perfect-Masonry

A way of created a perfect grid using javascript
JavaScript
10
star
11

shitty_news

For all your shitty news read http://shitty.news
Ruby
9
star
12

FBVersion

A Simple to use Like Gated Facebook Page
PHP
8
star
13

gulpRails

Enhancing the Rails Pipeline using Gulp
Ruby
5
star
14

rip-it-with-wordpress

A frontend build system for wordpress
PHP
3
star
15

DirectionJS

A javascript utility for getting direction and feedback from swipe
JavaScript
3
star
16

ModalCleaverView2

Use Cordova (iOS) as a componant
JavaScript
2
star
17

tessel-vl53l0x

An api wrapper for the Tessel and VL53L0X sensor
JavaScript
2
star
18

tessel-sound

Lasers + Sounds + Tessel
JavaScript
2
star
19

background.js

JavaScript
2
star
20

webbluetooth-examples

2
star
21

bash-minifyjs

A really easy method for combining multiple js files and minifying them with nodejs
Shell
2
star
22

Draw-Record

record canvas drawings and playback
JavaScript
1
star
23

TinyURL

PHP
1
star
24

racr

A game
JavaScript
1
star
25

docker_rails

a quick simple example and overview of docker and rails
Ruby
1
star
26

eventful

An event helper class
JavaScript
1
star
27

certbot-cloudfront

A docker container for adding Lets Encrypt to cloudfront using the certbot CLI
Shell
1
star
28

Social-Sharing

A simple javascript class that allows for easy social sharing
JavaScript
1
star
29

Vagrant-Quick-Start

A quick setup of vagrant and puppet for rails apps
Shell
1
star