Git Product home page Git Product logo

ordnung's Introduction

Ordnung.js

The 1kb alternative to Isotope.
Does grid column layouts in a jiffy, no globals asked.

Demo

Example

Install

npm install ordnung-js

Download

Usage

JS

var container = document.querySelector('.container');
var ordnung = new Ordnung(container);

ordnung.layout();

HTML

<div class="container">
  <div class="elem"></div>
  <div class="elem"></div>
  <div class="elem"></div>
  ...
</div>

Elements should be of equal width but variable height and float: left.
After layout, the container height will be adjusted to the condensed height of the elements.

CSS

To use Ordnung with media-queries, you need to use a hack for now: Clear the styles on window.resize and call ordnung.layout(). See example.

Compatibility

Ordnung.js uses CSS-transforms to move stuff around. This is a widely supported property, please consult Can I Use for specifics. As we're not implementing a bin packing algorithm, Ordnung only works with equal-width columns, just like many use cases with the original Isotope.

Performance

Plenty fast, albeit at the cost of being a one-trick pony.
Align 1000 elements x 100 runs โž median, on an Intel i7-3720QM.

Browser Ordnung ops/sec Other ops/sec
Chrome 46 32.26 10.64
Firefox 41 19.23 0.39
Safari 8 29.41 8.85

License

Ordnung.js is licensed under MIT.
You may use this library at will โ€“ if you mention the author.

Credits

Inspired by Isotope by Metafizzy
Made by Paul Solbach

ordnung's People

Contributors

jasonpolito avatar psolbach avatar snorpey 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

Watchers

 avatar  avatar

ordnung's Issues

Miscalculating height of the container after layout

Hi Paul,

Why are you subtracting the pageYoffset from the total height when the layout is done positioning?

container.style.height = (totalHeight - window.pageYOffset) + "px";

I would say that the total height is solely calculated from the elements, regardless of the scroll position at that moment. Or is there a specific reason to do so?

I have a case in which the total height is not calculated correctly: I am dynamically adding elements when the user scrolls to the bottom of the page. When this occurs the elements are reset and the layout method is recalled. However, the total height is wrong because of the subtraction.

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.