Skip to content

Justify elements to fit a certain width. Just like Flickr does.

License

Notifications You must be signed in to change notification settings

publicclass/justified-grid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

justified-grid

Justify elements to fit a certain width. Just like Flickr does.

It does not actually render the grid to the DOM but instead it lets you provide a render callback or get a list of positions and sizes to apply to the elements.

Example

[./examples/basic.html](Just a basic example:)

var elements = [
  {id: 1, width: 100, height: 80},
  {id: 2, width: 80, height: 100},
];

var grid = justifyGrid(elements);

grid.elements.forEach(function(entry) {
  // entry: {x: <x>, y: <y>, w: <width>, h: <height>, element: {...}};
});

CDN

To use this lib standalone without compiling you can use wzrd.in.

And thus simply:

<script src='https://wzrd.in/standalone/justified-grid@1.0'></script>
<script>
var grid = justifiedGrid([elements...]);
</script>

About

Justify elements to fit a certain width. Just like Flickr does.

Resources

License

Stars

Watchers

Forks

Packages

No packages published