# `ixfx-pan-text`

Pans overflowing text on hover or continuously in a loop. Use when a label is too long for its container and you want to reveal the full text without truncation.

```html
<span style="max-width: 120px; display: inline-block; overflow: hidden;">
  <ixfx-pan-text direction="end">A very long label that overflows</ixfx-pan-text>
</span>
```

---

## Modes

### `hover` (default)

Pans once while the cursor is over the element. Rests at the starting position when the cursor leaves.

```html
<ixfx-pan-text mode="hover">Long notification text goes here</ixfx-pan-text>
```

### `loop`

Pans repeatedly: pauses 2 seconds at the end, snaps back to start, then pans again until `stopLoop()` is called.

```html
<ixfx-pan-text mode="loop">Scrolling ticker text</ixfx-pan-text>
```

```js
const pan = document.querySelector('ixfx-pan-text');
pan.startLoop();   // Begin the loop
pan.stopLoop();    // Stop and snap back to rest position
```

The loop starts automatically when `mode="loop"` is set on an already-connected element, and stops automatically when `disabled` is set to `true`.

---

## Direction

| Direction | Rest position       | Pan direction |
|-----------|--------------------|---------------|
| `end`     | Start of text      | Left          |
| `start`   | End of text        | Right         |

```html
<!-- Shows end of text at rest, pans left on hover -->
<ixfx-pan-text direction="end">Very long label</ixfx-pan-text>

<!-- Shows start of text at rest, pans right on hover -->
<ixfx-pan-text direction="start">Very long label</ixfx-pan-text>
```

---

## Properties / attributes

| Attribute / Property | Type                  | Default  | Description                                           |
|---------------------|-----------------------|----------|-------------------------------------------------------|
| `direction`         | `'start'` \| `'end'`  | `'end'`  | Which end of the text is visible at rest              |
| `mode`              | `'hover'` \| `'loop'` | `'hover'`| Interaction mode                                      |
| `disabled`          | boolean               | `false`  | Disables panning and applies reduced opacity          |

---

## JavaScript API

```ts
const pan = document.querySelector('ixfx-pan-text');

// Programmatic loop control
pan.startLoop(); // Begin continuous panning
pan.stopLoop();  // Stop and snap back

// Check current state
if (pan.looping) {
  console.log('Pan is in loop mode');
}
```

---

## Accessibility

Respects `prefers-reduced-motion`. When reduced motion is preferred, the text stays in its rest position without animation.

---

## CSS custom properties

| Property            | Default   | Description          |
|---------------------|-----------|----------------------|
| `--disabled-opacity`| `0.5`     | Opacity when disabled |

---

## TypeScript types

```ts
import type { PanTextElement, PanTextMode } from 'ixfxfun-components';
```
