動きの質感を選ぶ(Easing)

このページでは、Framer Motion(useAnimate の ease)・GSAP(ease の文字列)・CSS Transition(cubic-bezier と linear())を使ったイージング(Easing)の実装パターンを、インタラクティブなデモとコードで確認できます。

イージング(Easing)とはアニメーションの「加速・減速の曲線」のこと。同じ距離・同じ時間でも、イージングによって動きの印象は大きく変わる。

「再生」ボタンを押すと全ての要素が同時にスタート。到着タイミングと動きの質感の違いを一目で比較できる。

Framer Motion

useAnimate の animate() に ease を渡す。名前(easeOut・circOut・backOut・anticipate など)か、cubic-bezier の4つの数の配列で指定する。bounce・elastic の名前は無く、式を関数で渡すか、type: "spring" で弾ませる。

プレビュー

読み込み中...

tsx
'use client';
import { useRef, useState } from 'react';
import { useAnimate, type Easing } from 'motion/react';

// ease は、名前(文字列)か cubic-bezier の4つの数の配列で指定する
const EASINGS: Easing[] = ['easeOut', 'circOut', 'backOut', 'anticipate'];
const BALL = 36;

export default function EasingCompare() {
  // scope の中の要素を、animate() にセレクタで渡せる
  const [scope, animate] = useAnimate();
  const trackRef = useRef<HTMLDivElement>(null);
  const [playing, setPlaying] = useState(false);

  const play = async () => {
    if (playing) return;
    setPlaying(true);
    // 移動距離はトラックの幅から計算する(ボールの幅ぶん引く)
    const x = (trackRef.current?.clientWidth ?? 256) - BALL;
    // 4つを同時に始め、すべて終わるまで待つ
    await Promise.all(
      EASINGS.map((ease, i) => animate(`.ball-${i}`, { x: [0, x] }, { duration: 1.2, ease })),
    );
    setPlaying(false);
  };

  const reset = () => {
    // 同じ値の新しいアニメーションを始めると、動いている途中のものは止まる
    animate('.ball', { x: 0 }, { duration: 0 });
    setPlaying(false);
  };

  return (
    <div ref={scope}>
      <div style={{ display: 'flex', gap: 12, marginBottom: 16 }}>
        <button onClick={play} disabled={playing}>再生</button>
        <button onClick={reset}>リセット</button>
      </div>
      {EASINGS.map((ease, i) => (
        <div key={String(ease)} style={{ display: 'flex', alignItems: 'center', gap: 12, marginBottom: 12 }}>
          <code style={{ width: 80 }}>{String(ease)}</code>
          <div ref={i === 0 ? trackRef : undefined} style={{ flex: 1, height: BALL, position: 'relative', overflow: 'hidden' }}>
            <div
              className={`ball ball-${i}`}
              style={{ width: BALL, height: BALL, borderRadius: '50%', background: '#c084fc', position: 'absolute' }}
            />
          </div>
        </div>
      ))}
    </div>
  );
}

AIプロンプトテンプレート

Next.js + Motion(motion/react)でイージングの比較デモを実装してください。
- 4つのボールを同時にスタートさせ、同じ距離・同じ時間で動きの違いを比べる
- useAnimate の animate() で x を動かし、ease に 'easeOut'・'circOut'・'backOut'・'anticipate' を指定する
- 移動距離はトラックの幅からボールの幅を引いて計算する
- 再生ボタン(再生中は押せない)とリセットボタンを付ける
- TypeScript / Tailwind CSS v4 を使用

このプロンプトはあくまでたたき台です。AIの回答はモデルやバージョン、会話の文脈によって毎回異なります。意図通りに動かない場合は、条件を追記・修正してお使いください。

💡 上記のデモは、React / Next.jsです。Next.jsの基本セットアップは 公式ドキュメントを参照してください。

実装方法の比較

項目Framer MotionGSAPCSS Transition
ease指定方法名前(文字列)・cubic-bezier の配列・関数文字列(power・back・bounce等)キーワード・cubic-bezier()・linear()
bounce・elastic名前は無い。式を関数で渡すか、spring で弾ませるbounce.out / elastic.out を標準で持つlinear() の折れ線で再現できる(点は自分で作る)
カスタムeasingcubicBezier()・関数を渡すCustomEaseプラグインcubic-bezier()・linear()
ease種類の豊富さ中(CSS準拠+spring)高(最多・bounce/elasticも自在)標準のキーワードは少ない。linear() でどんな曲線も折れ線で表せる