image-grid
Fast minimalist image-grid.
Layout elements with known aspect ratios in a grid as known from flickr or google image search.
Elements can be either raw or wrapped images with width
and height
attributes - or wrapper elements with a data-ratio
attribute.
- Very fast due to using managed stylesheets instead of inline styles.
- No library dependencies.
- And - oh yeah, it's fast!
Usage
image-grid will handle the layout of images in a container.
HTML
JS
var grid = ; // Create a new image-grid. var myImageGrid = ; // Set new options myImageGrid; // Deactivate the grid before removing it from the DOM. myImageGrid;myImageGridcontainerparentNode;
API
imageGrid
Create an image-grid to handle the layout of images in a container.
Arguments
selector
(string) - The selector of the image-grid container element.options
maxHeight
(number) - Optional. The maximum height of each row of images in the grid. Default is100
.margin
(number) - Optional. The margin between images in the grid. Default is10
.callback
(function) - Optional. This callback will be called everytime the layout is re-rendered. Default is null.
Returns
An image-grid instance.
image-grid instance methods
#.set
Can be used to change options after instance creation.
Arguments
options
See imageGridoptions
argument.
#.render
Can be called to refresh the layout manually.
Arguments
force
(boolean) - Optional. .
#.deactivate
Deactivates the grid and removes the stylesheet for the instance and events if necessary.
#.activate
Re-active deactivated instance.