# ngx-equalizer

> This library is inspired from [equalizer](https://github.com/skrajewski/Equalizer) jQuery library to keep HTML elements with equal height. The library is compatible with Angular 4+ because of its low peer dependencies.

Latest version **1.0.2** (published 2019-05-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install ngx-equalizer
pnpm add ngx-equalizer
yarn add ngx-equalizer
bun add ngx-equalizer
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2019-05-23 |
| First published | 2018-06-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 68 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Raphael De Freitas |
| Maintainers | raphy |
| Keywords | equalizer, angular, ngx, ng, height |

## Links

- npm: https://www.npmjs.com/package/ngx-equalizer
- Repository: https://github.com/Raphy/ngx-equalizer
- Homepage: https://raphy.github.io/ngx-equalizer
- Issues: https://github.com/Raphy/ngx-equalizer/issues
- npm.io page: https://npm.io/package/ngx-equalizer

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) ^1.9.0

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [mongoose-typescript](https://npm.io/package/mongoose-typescript.md) — 85 weekly downloads

## Recent versions

- 1.0.2 (latest) — 2019-05-23
- 1.0.1 — 2019-05-23
- 1.0.0 — 2018-06-08
- 0.0.1 — 2018-06-08

## README

# NgxEqualizerDemo

This library is inspired from [equalizer](https://github.com/skrajewski/Equalizer) jQuery library to keep HTML elements with equal height.  
The library is compatible with Angular 4+ because of its low peer dependencies.

Demo: [https://raphy.github.io/ngx-equalizer](https://raphy.github.io/ngx-equalizer)

## Install

Using YARN or NPM :
```bash
yarn add ngx-equalizer
# or
npm install ngx-equalizer --save
```

## Setup

Just import the `NgxEqualizerModule` when you need it in a module :

```typescript
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { NgxEqualizerModule } from '../../projects/ngx-equalizer/src/lib/ngx-equalizer.module';
import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    NgxEqualizerModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
```

## Usage

### Using the directives

The common usage is using the `equalizer` and `equalize` directives:

```html
<div equalizer>
  <div equalize>
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras ornare bibendum magna at consequat. Morbi ultrices, augue eget condimentum commodo, lacus odio sodales odio, non suscipit libero enim nec odio.
  </div>
  <div equalize>
    Sed lorem elit, bibendum sed varius in, pretium vitae ipsum.<br/>Curabitur vulputate mi risus, vitae pulvinar est egestas quis. Phasellus porta lacus eget velit condimentum, ac iaculis lacus volutpat.
  </div>
  <div equalize>
    Donec quam felis, vulputate non egestas facilisis, sagittis ac odio. Aliquam tincidunt, enim commodo congue volutpat, libero erat tempus massa, eu vehicula risus eros in metus. Etiam convallis, neque quis pellentesque sodales, metus leo gravida magna, dictum ullamcorper metus lectus eget erat. Vestibulum in leo a urna lacinia dapibus a at lacus.
  </div>
</div>
```

The `equalizer` directive is the parent and aims to "listen" the `equalize` children directives.

This way of using the library will automatically update the height of the elements event if the window is resized. 

### Using the service

A service is provided to equalize an array of `ElementRef`:

```typescript
import { ngAfterViewInit, Component, ElementRef, ViewChild } from '@angular/core';
import { EqualizerService } from '../../projects/ngx-equalizer/src/lib/equalizer.service';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent implements ngAfterViewInit {
  @ViewChild('paragraph1', {read: ElementRef})
  paragraph1: ElementRef;

  @ViewChild('paragraph2', {read: ElementRef})
  paragraph2: ElementRef;

  @ViewChild('paragraph3', {read: ElementRef})
  paragraph3: ElementRef;

  constructor(
    private readonly equalizerService: EqualizerService
  ) {
  }

  ngAfterViewInit(): void {
    this.equalizerService.equalizeElements([
      this.paragraph1,
      this.paragraph2,
      this.paragraph3,
    ]);
  }
}
```

```
<div>
  <div #paragraph1>
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras ornare bibendum magna at consequat. Morbi ultrices, augue eget condimentum commodo, lacus odio sodales odio, non suscipit libero enim nec odio.
  </div>
  <div #paragraph2>
    Sed lorem elit, bibendum sed varius in, pretium vitae ipsum.<br/>Curabitur vulputate mi risus, vitae pulvinar est egestas quis. Phasellus porta lacus eget velit condimentum, ac iaculis lacus volutpat.
  </div>
  <div #paragraph3>
    Donec quam felis, vulputate non egestas facilisis, sagittis ac odio. Aliquam tincidunt, enim commodo congue volutpat, libero erat tempus massa, eu vehicula risus eros in metus. Etiam convallis, neque quis pellentesque sodales, metus leo gravida magna, dictum ullamcorper metus lectus eget erat. Vestibulum in leo a urna lacinia dapibus a at lacus.
  </div>
</div>
```

This way of using the library will not update the height of the elements event if the window is resized. You have to handle by adding for example:

```typescript
  @HostListener('window:resize')
  private onWindowResize() {
    this.equalizerService.equalizeElements([
      this.paragraph1,
      this.paragraph2,
      this.paragraph3,
    ]);
  }
```

## License

The project is under MIT License.

---
_Source: https://npm.io/package/ngx-equalizer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
