Balanced Gallery is a jQuery plugin that evenly distributes photos across rows or columns, making the most of the space provided. Photos are scaled based on the size of the 'container' element by default, making Balanced Gallery a great choice for responsive websites. On a recent project we needed a similar photo gallery for Polymer based frontend, hece we created and are open sourcing <polymer-bg> : a polymer element to evenly distribute the photos across rows or columns using balanced gallery plugin.
Demo - https://qed42.github.io/polymer-bg/
Github project -- https://github.com/qed42/polymer-bg ( Test, Use, Fork and let us know of your issues )
Using polymer-bg Element in your Project
Install this using bower
Add the element element using html imports
Now you can use the tag, pass the images in the <img> tag and use the tag attributes to configure the settings as shown, exhaustive list of attributes below the example:
Available attributes
- auto-resize - re-partition and resize the images when the window size changes
- bg-background - the css properties of the gallery's containing element
- ideal-height - only used for horizontal galleries, defaults to half the containing element's height
- ideal-width - only used for vertical galleries, defaults to 1/4 of the containing element's width
- maintain-order - keeps images in their original order, setting to 'false' can create a slightly better balance between rows
- bg-orientation - 'horizontal' galleries are made of rows and scroll vertically; 'vertical' galleries are made of columns and scroll horizontally
- bg-padding - Space in pixels between images