Code Monkey home page Code Monkey logo

jquery.fillwidth's Introduction

jquery.fillwidth

A jQuery plugin that given a ul with images inside their lis will do some things to line them up so that everything fits inside their container nice and flush to the edges. Used throughout Artsy to make rows of images fit inside a fluid container and still stay flush without cropping the images.

Example Artsy Screenshot

See this example using placekitten.com for a basic implementation.

Usage

Create a DOM structure such as

<ul id='fill'>
  <li>
    <img>
  </li>
</ul>

Then apply the fillwidth plugin.

$('#fill').fillwidth()

Options

jquery.fillwidth takes a number of options you can pass to it's constructor.

resizeLandscapesBy { Number } (default 200)

Fillwidth will try to reduce images that are landscape (longer in width than height) up to a certain amount of pixels. Change this number to adjust the maximum amount of pixels fillwidth is allowed to reduce landscapes.

Landscape Reduce Example

resizeRowBy { Number } (default 30)

Fillwidth will try to subtly reduce the entire height of each row up to a certain amount of pixels. Change this number to adjust the maximum amount of pixels fillwidth is allowed to reduce each row by.

Row Height Reduce Example

beforeFillWidth { Function }

Pass in a callback before fillwidth does it's magic and tries to line up images

afterFillWidth { Function }

Pass in a callback right after fillwidth does it's magic and lines up images.

imageDimensions { Array }

If you know the dimensions of the child images before they finish loading, pass in an array of { width: X, height: X } hashes for a quicker fillwidth that calculates before the images finish loading. See the example for how this is done.

$('#fill').fillwidth({
  resizeLandscapesBy: 100,
  resizeRowBy: 40,
  beforeFillWidth: function() {},
  afterFillWidth: function() {},
  imageDimensions: [{ width: 100, height: 120 }]
})

To build

Fillwidth is written in coffeescript and must therefore be compiled before contributing updates.

  • Install node
  • Install node modules npm install
make build

License

MIT, see LICENSE.

jquery.fillwidth's People

Contributors

craigspaeth avatar dblock avatar zamiang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jquery.fillwidth's Issues

Fill in missing tests

It's been a while since putting in tests because of not being sure how this plugin would play out. But it's starting to come together so I think it's time to lock it in with tests.

Use HTML5 web workers for speedyness

It would be nice if the calculations were run & canceled in web workers.

For instance in the art.sy gene page view, when loading a bunch of artists it will attach a bunch of fill width plugins to each artist. Each artist could have like 100+ artworks, meaning like thousands of elements with several fillwidth handlers firing at once.

If we used web workers we could run these calculations on the side and not lock the scroll bar. Then if the user resized their window again we could cancel all of the workers and re-run them. Meaning no locked scroll bar and no excess calculations for impatient users.

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.