1.3.0 • Published 2 months ago

@meteora-digital/equalizer v1.3.0

Weekly downloads
2
License
MIT
Repository
github
Last release
2 months ago

Equalizer

Equalizer is an es6 Class which can be used to easily match the height of multiple elements using names to isolate matching groups.

Note: version 1.0.0 has breaking changes. Please update your code, or lock your version to 0.1.9 to avoid errors

Installation

yarn add @meteora-digital/equalizer
npm i @meteora-digital/equalizer

HTML Usage

<section data-equalize>
  <div data-equalize-watch></div>
  <div data-equalize-watch></div>
</section>
<section data-equalize="selector">
  <div data-equalize-watch="selector"></div>
  <div data-equalize-watch="selector"></div>
</section>
<section data-equalize="selector1, selector2">
  <div data-equalize-watch="selector1">
    <div data-equalize-watch="selector2"></div>
  </div>
  <div data-equalize-watch="selector1">
    <div data-equalize-watch="selector2"></div>
  </div>
</section>
import Equalizer from '@meteora-digital/equalizer';

document.addEventListener('DOMContentLoaded', () => {
    const equalizers = document.querySelectorAll('[data-equalize]');

    for (let index = 0; index < equalizers.length; index++) {
        const container = equalizers[index];

        new Equalizer({
            container,
            identifiers: container.getAttribute('data-equalize'),
            rows: true,
        });
    }
});

Usage

When you create a new Equalizer, you need to pass 3 arguments

ArgumentDescription
containerThe container is the element that is holding the items we want to resize
identifiersThe identifiers is a string of comma separated values that are used to match the elements we want to resize. The identifiers can be a selector, or a comma separated list of selectors. The container will be searched for child elements that have a matching identifier within a data-equalize-watch attribute.
rowsThe rows is a boolean that determines whether we want to resize the elements in rows or not. If not all elements will be the same height regardless of their position on the page.
throttleThe throttle is a number that determines how often the equalizer will check for changes per update(). The default is 0.
debounceThe debounce is a number that determines how long the equalizer will wait after the last resize event before updating. The default is 100.
mutationsSettings that will be injected into the MutationObserver. The default is { childList: true, subtree: false }
## Events

You can call an `on` method on the Equalizer instance to listen for events.

```es6
equalizer.on('resize', () => {
    console.log('resize');
});
EventDescription
resizeThis event is fired when the Equalizer is resized.
beforeResizeThis event is fired before the Equalizer is resized
updateThis event is fired when the Equalizer is updated.
beforeUpdateThis event is fired before the Equalizer is updated.

License

MIT

1.3.0

2 months ago

1.2.5

3 months ago

1.2.4

3 months ago

1.2.3

3 months ago

1.2.2

5 months ago

1.2.0

9 months ago

1.2.1

9 months ago

1.1.1

2 years ago

1.1.0

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.0.4

2 years ago

1.0.2

2 years ago

1.0.3

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.1.8

3 years ago

0.1.9

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.4

3 years ago

0.1.5

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago

0.0.5

3 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago

0.0.0

4 years ago