AIGPAIGP

Framer Motion Image Gallery: Hover Effects Prompt & Code

P

Prompt

Create an interactive image gallery using Framer Motion with hover animations, layout animations, and smooth transitions between grid and detailed views.

CODE PREVIEW

エディタを読み込み中…

AIとの対話に追加する一言

プロンプトと一緒にコピーして、AIがより正確に意図を汲み取れるようにします

このコードをそのまま使いたいので、CDNリンクも含めた完全なHTMLファイルとして出力してください。

初心者なので、各行にコメントを追加して、何をしているか説明してください。

このコードをWordPressのテーマに組み込む方法も教えてください。

動作確認済みのコードをお願いします。エラーが出る場合の対処法も含めて。

このインタラクティブ画像ギャラリーは、Framer Motionの主要な機能をいくつか実演しています:

コアコンセプト:

  • レイアウトアニメーション:layoutIdを使用したグリッド表示と詳細表示間のスムーズな遷移
  • ホバー効果:ホバー時のスケールアニメーションとオーバーレイ表示
  • AnimatePresence:モーダルコンポーネントのクリーンな表示/非表示アニメーション
  • スプリング物理:スプリングトランジションによる自然な動き
  • ジェスチャーサポート:組み込みのホバーとタップジェスチャーアニメーション

主な機能:

  1. レスポンシブデザインのグリッドレイアウト
  2. ホバー時の画像拡大とテキストオーバーレイ表示
  3. 画像クリックで詳細ビューを開く
  4. グリッドとモーダル間のスムーズなレイアウト遷移
  5. 背景ディミングとフォーカス管理
  6. 回転効果付きインタラクティブ閉じるボタン
  7. 詳細ビュー内の段階的テキストアニメーション

学習ポイント:

  • 共有要素トランジションのためのlayoutIdの使用
  • 複数のアニメーションプロパティの組み合わせ
  • Reactフックを使用したアニメーション状態の管理
  • レスポンシブなジェスチャーベースのインタラクションの作成
  • アクセシブルなモーダルパターンの実装

Prompt Overview

This prompt instructs an AI coding assistant to generate a React-based image gallery component powered by Framer Motion, complete with hover animations, layout transitions, and a smooth toggle between a grid overview and an expanded detail view. It is especially useful for frontend developers who want a polished, production-ready UI pattern without writing every animation keyframe from scratch. The resulting code typically demonstrates Framer Motion's layoutId for shared-element transitions, whileHover for scale or overlay effects, and AnimatePresence for mounting and unmounting views gracefully.

Real-world applications include portfolio sites, e-commerce product listings, photography showcases, and any interface where visual content needs to feel responsive and engaging. To reproduce it, paste the prompt into a capable code-generation model such as GPT-4o or Claude 3.5, then drop the output into a Next.js or Vite project with Framer Motion installed. For variations, try adding drag-to-reorder functionality, staggered entrance animations, or a lightbox modal overlay to further enrich the user experience.

Was this prompt helpful?

Comments

Comments appear after moderation

この記事が役に立ったら投げ銭で応援

Apple Pay / Google Pay / カード (Visa/Mastercard/JCB/Amex) / Link / Alipay / WeChat Pay 対応 · Stripeで安全に決済

開発者が選ぶ最強ツール集

運営者が毎日使っているツール・ガジェット 6選

見る
Homeヘルプ