Coder Social home page Coder Social logo

balancedgallery's Introduction

Balanced Gallery

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.

Demos

Horizontal Gallery Demo

Vertical Gallery Demo

Quick Start

Import JQuery and the Plugin:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript" src="jquery.balanced-gallery.min.js"></script>

Call the plugin on the element containing the gallery's images:

// wait for the page to load
$(window).load(function() {
   $('#myGallery').BalancedGallery({ /* options */ });
});

Options

var defaults = {
            autoResize: true,                   // re-partition and resize the images when the window size changes
            background: null,                   // the css properties of the gallery's containing element
            idealHeight: null,                  // ideal row height, only used for horizontal galleries, defaults to half the containing element's height
            idealWidth: null,                   // ideal column width, only used for vertical galleries, defaults to 1/4 of the containing element's width
            maintainOrder: true,                // keeps images in their original order, setting to 'false' can create a slightly better balance between rows
            orientation: 'horizontal',          // 'horizontal' galleries are made of rows and scroll vertically; 'vertical' galleries are made of columns and scroll horizontally
            padding: 5,                         // pixels between images
            shuffleUnorderedPartitions: true,   // unordered galleries tend to clump larger images at the begining, this solves that issue at a slight performance cost
            viewportHeight: null,               // the assumed height of the gallery, defaults to the containing element's height
            viewportWidth: null                 // the assumed width of the gallery, defaults to the containing element's width
        };

Browser Compatibility

Tested and working in:

  • Chrome
  • Safari
  • FireFox
  • IE 9+
  • Mobile Safari
  • Mobile Chrome

Contributing

If you'd like to contribute a feature or bugfix, that's awesome. Go for it. As of right now I don't have a specific set of guidelines for contributions but try to follow the plugin's current coding style.

License

Copyright (c) 2013 Ryan Epp Licensed under the WTFPL license.

Acknowledgements

Inspired by crispymtn. Linear partitioning algorithm ported from Óscar López

balancedgallery's People

Contributors

repp avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.