# Constants


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

## Type Aliases

``` python
# Test CardRole type
role: CardRole = "focused"
assert role == "focused"
role = "context"
assert role == "context"
print("CardRole type alias tests passed!")
```

    CardRole type alias tests passed!

## Scroll Navigation Constants

Thresholds for converting mouse wheel events into card navigation.

``` python
assert SCROLL_THRESHOLD == 1
assert NAVIGATION_COOLDOWN == 100
assert TRACKPAD_COOLDOWN == 250
print("Scroll constants tests passed!")
```

    Scroll constants tests passed!

## Touch Navigation Constants

Thresholds for converting touch gestures into card navigation and scale
adjustments. Touch-and-drag uses the focused slot height as the step
distance; these constants govern the simple-swipe fallback, momentum
decay after a fast swipe, and pinch-to-zoom sensitivity.

``` python
assert TOUCH_SWIPE_THRESHOLD == 30
assert TOUCH_MOMENTUM_MIN_VELOCITY == 0.5
assert TOUCH_MOMENTUM_FRICTION == 0.95
assert TOUCH_PINCH_THRESHOLD == 30
assert TOUCH_VELOCITY_SAMPLES == 5
print("Touch constants tests passed!")
```

    Touch constants tests passed!

## localStorage Key Patterns

Key templates for persisting viewport preferences to localStorage. The
prefix is interpolated at runtime to support multi-instance.

------------------------------------------------------------------------

<a
href="https://github.com/cj-mills/cjm-fasthtml-card-stack/blob/main/cjm_fasthtml_card_stack/core/constants.py#L48"
target="_blank" style="float:right; font-size:smaller">source</a>

### auto_count_storage_key

``` python

def auto_count_storage_key(
    prefix:str, # Card stack instance prefix
)->str: # localStorage key for auto card count mode

```

*Generate localStorage key for auto card count mode.*

------------------------------------------------------------------------

<a
href="https://github.com/cj-mills/cjm-fasthtml-card-stack/blob/main/cjm_fasthtml_card_stack/core/constants.py#L42"
target="_blank" style="float:right; font-size:smaller">source</a>

### card_count_storage_key

``` python

def card_count_storage_key(
    prefix:str, # Card stack instance prefix
)->str: # localStorage key for card count

```

*Generate localStorage key for card count.*

------------------------------------------------------------------------

<a
href="https://github.com/cj-mills/cjm-fasthtml-card-stack/blob/main/cjm_fasthtml_card_stack/core/constants.py#L36"
target="_blank" style="float:right; font-size:smaller">source</a>

### scale_storage_key

``` python

def scale_storage_key(
    prefix:str, # Card stack instance prefix
)->str: # localStorage key for card scale

```

*Generate localStorage key for card scale.*

------------------------------------------------------------------------

<a
href="https://github.com/cj-mills/cjm-fasthtml-card-stack/blob/main/cjm_fasthtml_card_stack/core/constants.py#L30"
target="_blank" style="float:right; font-size:smaller">source</a>

### width_storage_key

``` python

def width_storage_key(
    prefix:str, # Card stack instance prefix
)->str: # localStorage key for card width

```

*Generate localStorage key for card width.*

``` python
# Test storage key generation
assert width_storage_key("cs0") == "cs0-card-width"
assert scale_storage_key("cs0") == "cs0-card-scale"
assert card_count_storage_key("cs0") == "cs0-card-count"
assert auto_count_storage_key("cs0") == "cs0-card-count-auto"

# Multi-instance keys are unique
assert width_storage_key("text") != width_storage_key("vad")
assert auto_count_storage_key("text") != auto_count_storage_key("vad")
print("Storage key tests passed!")
```

    Storage key tests passed!

## Viewport Defaults

``` python
assert DEFAULT_VISIBLE_COUNT == 1
assert DEFAULT_CARD_WIDTH == 80
assert DEFAULT_CARD_SCALE == 100
print("Viewport default tests passed!")
```
