# core/observers/panel.observer.ts

> 25 lines of code and 4 definitions.

Tree: Site tree
Language: typescript
Layer: application
Canonical: https://banes-lab.com/anatomy/tree#file-core-observers-panel-observer-ts
Source text: https://banes-lab.com/assets/sources/source.039a35618486f998a5548768b1f80ab71d8913ce650c09dbc3ecbd9381f4ade0.generated.txt

## Definitions

- `cancel` (lexical_declaration, line 6, exported)
- `observeArming` (lexical_declaration, line 3, exported)
- `armed` (lexical_declaration, line 4, exported)
- `pending` (lexical_declaration, line 5, exported)

## Used by

- [presentation/components/stage.component.ts](https://banes-lab.com/source/tree/presentation/components/stage.component.ts.md)

## Source

```typescript
import { PANEL_ARMED_CLASS, PANEL_ARM_MS } from "#configuration/constants/panel.constants";

export const observeArming = function observeArming(element: HTMLElement): () => boolean {
    let armed = false;
    let pending: ReturnType<typeof setTimeout> | null = null;
    const cancel = function cancel(): void {
        if (pending !== null) {
            clearTimeout(pending);
            pending = null;
        }
    };
    element.addEventListener("pointerenter", () => {
        cancel();
        pending = setTimeout(() => {
            armed = true;
            pending = null;
            element.classList.add(PANEL_ARMED_CLASS);
        }, PANEL_ARM_MS);
    });
    element.addEventListener("pointerleave", () => {
        cancel();
        armed = false;
        element.classList.remove(PANEL_ARMED_CLASS);
    });
    return () => armed;
};
```
