Skip to content

Commit

Permalink
add more examples to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Maximilianos committed Nov 19, 2015
1 parent 85e1b7f commit 2215c8c
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion README.md
Expand Up @@ -10,7 +10,9 @@ Find [eqheights on npm](https://www.npmjs.com/package/eqheights)
npm i eqheights
```

## Usage
## Usage Examples

Simplest, one off:

```javascript
import eqheights from 'eqheights';
Expand All @@ -24,6 +26,41 @@ const elements = document.querySelectorAll('.list-items');
eqheights(elements);
```

Responsive:

```javascript
import eqheights from 'eqheights';

const gridEqualizer = eqheights('.grid-items');
window.addEventListener('resize', gridEqualizer.recalc);
```

Togglable:

```javascript
import eqheights from 'eqheights';

// autorun = false because we
// want to initialize only,
// not run eqheights yet
const {recalc, clear} = eqheights('.grid-items', {autorun: false});

const container = document.getElementById('grid');
document
.getElementById('toggle')
.addEventListener('click', () => {
Array.prototype.indexOf(container.classList, 'active') < 0
? recalc()
: clear();

container.classList.toggle('active');
});
```

Togglable and Responsive:

See this codepen: http://codepen.io/Maximilianos/pen/OyBYvv?editors=001

## License

MIT © [Max GJ Panas](maxpanas.com)

0 comments on commit 2215c8c

Please sign in to comment.