Setting the file. One moment. Scene · Music To Video · heygen-com/hyperframes · Skills DocsGsap Min
(opens in a new tab)
references/motion-primitives/mosaic-pack/scene.html
HTML·89 lines·3 KB
7 --hg-bg: #0a0a0f;
8 --hg-fg: #f5f5fa;
9 --hg-dim: #6b6b78;
10 }
11 * {
12 margin: 0;
13 padding: 0;
14 box-sizing: border-box;
15 }
16 .stage {
17 position: absolute;
18 inset: 0;
19 display: flex;
20 align-items: center;
21 justify-content: center;
22 }
23 .grid {
24 display: grid;
25 grid-template-columns: repeat(6, 200px);
26 grid-template-rows: repeat(4, 200px);
27 gap: 18px;
28 }
29 .tile {
30 border-radius: 14px;
31 will-change: transform, opacity;
32 }
33 </style>
34 <div class="stage">
35 <div class="grid" id="grid"></div>
36 </div>
37 <script>
38 window.__timelines = window.__timelines || {};
39 const tl = gsap.timeline({ paused: true });
40
41 // Deterministic palette + grid build (6x4 = 24 cells).
42 const PALETTE = ["#7c3aed", "#a855f7", "#f5f5fa", "#2a2a3a", "#b56dff", "#6b6b78"];
43 const COLS = 6;
44 const ROWS = 4;
45 const COUNT = COLS * ROWS;
46 const grid = document.getElementById("grid");
47 const tiles = [];
48 for (let i = 0; i < COUNT; i++) {
49 const tile = document.createElement("div");
50 tile.className = "tile";
51 tile.style.background = PALETTE[i % PALETTE.length];
52 grid.appendChild(tile);
53 tiles.push(tile);
54 }
55
56 // Scatter each tile from a deterministic offset/rotation, then pack into place.
57 // Land order ripples diagonally (col + row) for a deterministic "assembling" feel.
58 const STEP = 0.07;
59 for (let i = 0; i < COUNT; i++) {
60 const col = i % COLS;
61 const row = Math.floor(i / COLS);
62 const dx = (((i * 53) % 200) - 100) * 9; // far-flung scatter X
63 const dy = (((i * 89) % 200) - 100) * 7; // far-flung scatter Y
64 const rot = ((i * 37) % 80) - 40; // deterministic tilt
65 const order = col + row; // diagonal land sequence
66 tl.fromTo(
67 tiles[i],
68 { x: dx, y: dy, rotation: rot, scale: 0.6, autoAlpha: 0.15 },
69 {
70 x: 0,
71 y: 0,
72 rotation: 0,
73 scale: 1,
74 autoAlpha: 1,
75 duration: 0.6,
76 ease: "back.out(1.6)",
77 },
78 0.1 + order * STEP,
79 );
80 }
81
82 // Settle the packed poster with a tiny breath so the loop seats cleanly.
83 tl.to("#grid", { scale: 1.02, duration: 0.18, ease: "power2.out" }, 1.9);
84 tl.to("#grid", { scale: 1, duration: 0.32, ease: "power2.inOut" }, 2.08);
85
86 window.__timelines["mosaic-pack"] = tl;
87 </script>
88 </div>
89</template>