本文へスキップ

TOP / MOTION LAB / ギャラリー

ギャラリー 読了目安 3分

スワップグリッド

概要

サムネイルをクリックすると、その画像がメイン枠へ滑らかに移動し、元のメイン画像がサムネイル位置へ入れ替わる、商品ギャラリー向けのレイアウトトランジション。

使用技術

実装ポイント

コアスニペット

// 1. 現在の状態を記録
const state = Flip.getState(products);
// 2. 属性(グリッド位置)を交換
const currentGrid = el.dataset.grid;
active.dataset.grid = currentGrid;
el.dataset.grid = "img-1";
active = el;
// 3. アニメーション実行
Flip.from(state, {
  duration: 0.4,
  absolute: true,
  ease: "power2.inOut",
  scale: true,
});