本文へスキップ

TOP / MOTION LAB / スクロール

スクロール 読了目安 4分

慣性スクロール・パララックス

概要

Lenisによる滑らかな慣性スクロールを土台に、ドラッグ慣性スライダー・マグネティックUI・カスタムカーソル・3Dチルト・液体風CTAボタンなど、物理ベースのインタラクションを網羅したリッチな一枚もの。

使用技術

実装ポイント

コアスニペット

Draggable.create("#draggable-track", {
  type: "x",
  onDrag: function () {
    velocityTracker.velocity = this.x - velocityTracker.lastX;
    velocityTracker.lastX = this.x;
  },
  onDragEnd: function () {
    const inertiaX = this.x + velocityTracker.velocity * 20;
    const minX = containerWidth - trackWidth - paddingLeft;
    const clampedX = Math.max(minX, Math.min(maxX, inertiaX));
    gsap.to(this.target, { x: clampedX, duration: 1.2, ease: "power3.out" });
  },
});