# @aster-js/dom

> Aster DOM library part of Aster js library

Latest version **1.1.0** (published 2024-01-14) · ISC license · 0 weekly downloads

## Install

```sh
npm install @aster-js/dom
pnpm add @aster-js/dom
yarn add @aster-js/dom
bun add @aster-js/dom
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2024-01-14 |
| First published | 2022-01-19 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 19.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | sebdoucet |
| Maintainers | aster-js |

## Links

- npm: https://www.npmjs.com/package/@aster-js/dom
- Repository: https://github.com/asterlibraryjs/aster-js-dom
- Homepage: https://github.com/asterlibraryjs/aster-js-dom#readme
- Issues: https://github.com/asterlibraryjs/aster-js-dom/issues
- npm.io page: https://npm.io/package/@aster-js/dom

## Dependencies (3)

- [tslib](https://npm.io/package/tslib.md) ^2.6.2
- [@aster-js/core](https://npm.io/package/@aster-js/core.md) ^1.3.0
- [@aster-js/async](https://npm.io/package/@aster-js/async.md) ^1.4.1

## Recent versions

- 1.1.0 (latest) — 2024-01-14
- 1.0.2 — 2022-05-09
- 1.0.1 — 2022-01-19
- 1.0.0 — 2022-01-19

## README

# @aster-js/dom

In its current state, just a serie of basic helpers.


## Dom Elements Positions

```ts
import { isOver, isVisible } from "@aster-js/dom/utilities";

const el = document.getElementById("my-element");

/* Check if the element is on screen */
if(isVisible(el)) {
    //
}

/* Check if the coordinate are in the element bounds */
if(isInBounds(el, 30, 30)) {
    //
}
```

## Dom Elements Events

### Disposable event listener
This will essentially helps to work with disposable and manage the same way every dependency removal.
```ts
import { dom } from "@aster-js/dom";

const el = document.getElementById("my-element");

const clickListener = dom.on(el, "hug", ()=> console.warn("Hugging.."));

/* ... later, to remove the listener ...*/

/* The following import is not required but its more safe to use it */
import { IDisposable } from "@aster-js/core";

IDisposable.safeDispose(clickListener);
```

### AsyncIterable for events
This will help to pipe events into async iterable various helpers...
```ts
const result: any[] = [];
for await (const { detail } of dom.each<CustomEvent>(el, "hug")) {
    result.push(detail);
    if (result.length >= 3) break;
}
// Get the last 3 hugs :)
```

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