
# 構文

Glaze のアニメーション文字列は、シンプルなパターンに従います。

```
[breakpoint][selector]:state:properties
```

詳しく見ていきましょう。

## 状態

アニメーションには状態が必要です。`from`、`to`、またはその両方を指定します。

### from

この値から始めて、要素の自然な状態までアニメーションします。

```html
<div data-animate="from:opacity-0"></div>
```

### to

現在の状態から指定した値までアニメーションします。

```html
<div data-animate="to:xPercent-50"></div>
```

### fromTo

2つの特定の状態間をアニメーションさせるには、両方を使います（[GSAP](<https://gsap.com/docs/v3/GSAP/gsap.fromTo()>)のfromTo）。

```html
<div data-animate="from:opacity-0.5 to:opacity-1"></div>
```

## プロパティ

状態の後に、パイプ（`|`）で区切ってアニメーションのプロパティを並べます。

```html
<div data-animate="to:opacity-1|yPercent-10|duration-0.5"></div>
```

文字列はダッシュ（`-`）で分割して解析されます。前半がプロパティ名、後半がその値です。値は適切な型（数値、ブール値、文字列）に自動変換されます。

### ネストされたプロパティ

ネストされた値にはドットを使います。

```html
<div data-animate="to:scale.x-2|scale.y-2"></div>
```

これにより `{ scale: { x: 2, y: 2 } }` が作成されます。

### 負の値

負の値は角括弧で囲みます。

```html
<div data-animate="to:xPercent-[-50]"></div>
```

### スペースを含む値

スペースの代わりにアンダースコアを使います。

```html
<div data-animate="to:boxShadow-[0_0_50px_20px_red]"></div>
```

## ブレークポイント

特定の画面サイズでのみアニメーションを実行するには、先頭に `@breakpoint:` を追加します。

```html
<div data-animate="@sm:from:opacity-0"></div>
```

これは、`sm` ブレークポイントに一致する画面でのみアニメーションします。

## セレクター

ブラケット記法を使うと、要素自体ではなく子要素を対象にできます：

```html
<div data-animate="[&>h1]:to:opacity-1|stagger-0.25">
  <h1>One</h1>
  <h1>Two</h1>
  <h1>Three</h1>
</div>
```

`&`は親要素を指すため、`[&>h1]`は「すべてのh1子要素」を意味します。

ブレークポイントとセレクターを組み合わせることもできます：

```html
<div data-animate="@sm:[&>h1]:to:opacity-1|stagger-0.25">
  <h1>...</h1>
  <h1>...</h1>
  <h1>...</h1>
</div>
```

## 組み合わせる

複雑な例を見てみましょう：

```html
<div
  data-animate="@lg:[&>div]:from:opacity-0|y-50|stagger-0.1|duration-0.5|ease-power2.out"
>
  <div>Card 1</div>
  <div>Card 2</div>
  <div>Card 3</div>
</div>
```

これは「大画面では、すべてのdiv子要素をopacity 0、y 50からスタガー付きでアニメーションする」という意味です。
