# @a11y-ngx/window-resize

> A window resize listener service

Latest version **1.0.5** (published 2025-11-25) · MPL-2.0 license · 0 weekly downloads

## Install

```sh
npm install @a11y-ngx/window-resize
pnpm add @a11y-ngx/window-resize
yarn add @a11y-ngx/window-resize
bun add @a11y-ngx/window-resize
```

## Health

**Score 55/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2025-11-25 |
| First published | 2022-10-02 |
| Weekly downloads | 0 |
| License | MPL-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 26.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Luciano Del Vacchio |
| Maintainers | ldv |
| Keywords | window, resize, listener, service, angular |

## Links

- npm: https://www.npmjs.com/package/@a11y-ngx/window-resize
- Homepage: https://github.com/LDV2k3/a11y-libraries/tree/master/projects/a11y-ngx/window-resize#readme
- Issues: https://github.com/LDV2k3/a11y-libraries/issues
- npm.io page: https://npm.io/package/@a11y-ngx/window-resize

## Dependencies (1)

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

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 1.0.5 (latest) — 2025-11-25
- 1.0.4 — 2025-10-31
- 1.0.3 — 2024-09-18
- 1.0.2 — 2024-04-08
- 1.0.1 — 2024-04-08
- 1.0.0 — 2022-10-02

## README

# Window Resize

A simple window resize listener singleton service.

This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 12.2.0.

## Installation

1. Install npm package:

   `npm install @a11y-ngx/window-resize --save`

2. Import `WindowResizeService` into your typescript file:

```typescript
import { WindowResizeService } from '@a11y-ngx/window-resize';

constructor(private resizeService: WindowResizeService) {}
```

## Use

Subscribe to the service's `event` which will return an object of type `WindowResize` containing the window's width & height.

```typescript
import { WindowResizeService, WindowResize } from '@a11y-ngx/window-resize';
import { debounceTime } from 'rxjs/operators';
...
@Directive({ selector: '[...]' })
export class MyDirective implements OnDestroy {
    private readonly destroy$: Subject<void> = new Subject<void>();

    constructor(
        private resizeService: WindowResizeService
    ) {
        this.resizeService.event
            .pipe(debounceTime(100), takeUntil(this.destroy$))
            .subscribe((windowSize: WindowResize) => this.updateSize(windowSize));
    }

    updateSize(windowSize: WindowResize): void {
        const windowWidth: windowSize.width;
        const windowHeight: windowSize.height;
        ...
    }

    ngOnDestroy(): void {
        this.destroy$.next();
        this.destroy$.complete();
    }
}
```

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