|
| 1 | +const frames = [ |
| 2 | + { |
| 3 | + id: 1, |
| 4 | + video: "https://static.cdn-luma.com/files/981e483f71aa764b/Company%20Thing%20Exported.mp4", |
| 5 | + corner: "https://static.cdn-luma.com/files/bcf576df9c38b05f/1_corner_update.png", |
| 6 | + edgeHorizontal: "https://static.cdn-luma.com/files/bcf576df9c38b05f/1_vert_update.png", |
| 7 | + edgeVertical: "https://static.cdn-luma.com/files/bcf576df9c38b05f/1_hori_update.png", |
| 8 | + }, |
| 9 | + { |
| 10 | + id: 2, |
| 11 | + video: "https://static.cdn-luma.com/files/58ab7363888153e3/WebGL%20Exported%20(1).mp4", |
| 12 | + corner: "https://static.cdn-luma.com/files/bcf576df9c38b05f/2_corner_update.png", |
| 13 | + edgeHorizontal: "https://static.cdn-luma.com/files/bcf576df9c38b05f/2_vert_update.png", |
| 14 | + edgeVertical: "https://static.cdn-luma.com/files/bcf576df9c38b05f/2_hori_update.png", |
| 15 | + }, |
| 16 | + { |
| 17 | + id: 3, |
| 18 | + video: "https://static.cdn-luma.com/files/58ab7363888153e3/Jitter%20Exported%20Poster.mp4", |
| 19 | + corner: "https://static.cdn-luma.com/files/3d36d1e0dba2476c/3_Corner_update.png", |
| 20 | + edgeHorizontal: "https://static.cdn-luma.com/files/3d36d1e0dba2476c/3_hori_update.png", |
| 21 | + edgeVertical: "https://static.cdn-luma.com/files/3d36d1e0dba2476c/3_Vert_update.png", |
| 22 | + }, |
| 23 | + { |
| 24 | + id: 4, |
| 25 | + video: "https://static.cdn-luma.com/files/58ab7363888153e3/Exported%20Web%20Video.mp4", |
| 26 | + corner: "https://static.cdn-luma.com/files/9e67e05f37e52522/4_corner_update.png", |
| 27 | + edgeHorizontal: "https://static.cdn-luma.com/files/9e67e05f37e52522/4_hori_update.png", |
| 28 | + edgeVertical: "https://static.cdn-luma.com/files/9e67e05f37e52522/4_vert_update.png", |
| 29 | + }, |
| 30 | + { |
| 31 | + id: 5, |
| 32 | + video: "https://static.cdn-luma.com/files/58ab7363888153e3/Logo%20Exported.mp4", |
| 33 | + corner: "https://static.cdn-luma.com/files/9e67e05f37e52522/5_corner_update.png", |
| 34 | + edgeHorizontal: "https://static.cdn-luma.com/files/9e67e05f37e52522/5_hori_update.png", |
| 35 | + edgeVertical: "https://static.cdn-luma.com/files/9e67e05f37e52522/5_verti_update.png", |
| 36 | + }, |
| 37 | + { |
| 38 | + id: 6, |
| 39 | + video: "https://static.cdn-luma.com/files/58ab7363888153e3/Animation%20Exported%20(4).mp4", |
| 40 | + corner: "https://static.cdn-luma.com/files/1199340587e8da1d/6_corner.png", |
| 41 | + edgeHorizontal: "https://static.cdn-luma.com/files/1199340587e8da1d/6_corner-1.png", |
| 42 | + edgeVertical: "https://static.cdn-luma.com/files/1199340587e8da1d/6_vert.png", |
| 43 | + }, |
| 44 | + { |
| 45 | + id: 7, |
| 46 | + video: "https://static.cdn-luma.com/files/58ab7363888153e3/Illustration%20Exported%20(1).mp4", |
| 47 | + corner: "https://static.cdn-luma.com/files/b80b5aa00ccc33bd/7_corner.png", |
| 48 | + edgeHorizontal: "https://static.cdn-luma.com/files/b80b5aa00ccc33bd/7_hori.png", |
| 49 | + edgeVertical: "https://static.cdn-luma.com/files/b80b5aa00ccc33bd/7_vert.png", |
| 50 | + }, |
| 51 | + { |
| 52 | + id: 8, |
| 53 | + video: "https://static.cdn-luma.com/files/58ab7363888153e3/Art%20Direction%20Exported.mp4", |
| 54 | + corner: "https://static.cdn-luma.com/files/981e483f71aa764b/8_corner.png", |
| 55 | + edgeHorizontal: "https://static.cdn-luma.com/files/981e483f71aa764b/8_hori.png", |
| 56 | + edgeVertical: "https://static.cdn-luma.com/files/981e483f71aa764b/8_verticle.png", |
| 57 | + }, |
| 58 | + { |
| 59 | + id: 9, |
| 60 | + video: "https://static.cdn-luma.com/files/58ab7363888153e3/Product%20Video.mp4", |
| 61 | + corner: "https://static.cdn-luma.com/files/981e483f71aa764b/9_corner.png", |
| 62 | + edgeHorizontal: "https://static.cdn-luma.com/files/981e483f71aa764b/9_hori.png", |
| 63 | + edgeVertical: "https://static.cdn-luma.com/files/981e483f71aa764b/9_vert.png", |
| 64 | + }, |
| 65 | +] |
| 66 | + |
| 67 | +const grid = document.getElementById("grid") |
| 68 | +const showFramesCheckbox = document.getElementById("showFrames") |
| 69 | +const autoplayAllCheckbox = document.getElementById("autoplayAll") |
| 70 | + |
| 71 | +function createFrame(frame) { |
| 72 | + const frameElement = document.createElement("div") |
| 73 | + frameElement.className = "frame" |
| 74 | + frameElement.innerHTML = ` |
| 75 | + <video src="${frame.video}" loop muted ${autoplayAllCheckbox.checked ? "autoplay" : ""}> |
| 76 | + <div class="frame-border"> |
| 77 | + <img src="${frame.corner}" class="corner-tl"> |
| 78 | + <img src="${frame.corner}" class="corner-tr"> |
| 79 | + <img src="${frame.corner}" class="corner-bl"> |
| 80 | + <img src="${frame.corner}" class="corner-br"> |
| 81 | + <div class="edge-top" style="background-image: url(${frame.edgeHorizontal})"></div> |
| 82 | + <div class="edge-bottom" style="background-image: url(${frame.edgeHorizontal})"></div> |
| 83 | + <div class="edge-left" style="background-image: url(${frame.edgeVertical})"></div> |
| 84 | + <div class="edge-right" style="background-image: url(${frame.edgeVertical})"></div> |
| 85 | + </div> |
| 86 | + ` |
| 87 | + |
| 88 | + const video = frameElement.querySelector("video") |
| 89 | + const frameBorder = frameElement.querySelector(".frame-border") |
| 90 | + |
| 91 | + frameElement.addEventListener("mouseenter", () => { |
| 92 | + frameElement.style.transform = "scale(1.1)" |
| 93 | + if (!autoplayAllCheckbox.checked) { |
| 94 | + video.play() |
| 95 | + } |
| 96 | + if (showFramesCheckbox.checked) { |
| 97 | + frameBorder.style.opacity = "1" |
| 98 | + } |
| 99 | + }) |
| 100 | + |
| 101 | + frameElement.addEventListener("mouseleave", () => { |
| 102 | + frameElement.style.transform = "scale(1)" |
| 103 | + if (!autoplayAllCheckbox.checked) { |
| 104 | + video.pause() |
| 105 | + } |
| 106 | + frameBorder.style.opacity = "0" |
| 107 | + }) |
| 108 | + |
| 109 | + return frameElement |
| 110 | +} |
| 111 | + |
| 112 | +function initializeGrid() { |
| 113 | + grid.innerHTML = "" |
| 114 | + frames.forEach((frame) => { |
| 115 | + const frameElement = createFrame(frame) |
| 116 | + grid.appendChild(frameElement) |
| 117 | + }) |
| 118 | +} |
| 119 | + |
| 120 | +showFramesCheckbox.addEventListener("change", () => { |
| 121 | + const frameBorders = document.querySelectorAll(".frame-border") |
| 122 | + frameBorders.forEach((border) => { |
| 123 | + border.style.opacity = showFramesCheckbox.checked ? "1" : "0" |
| 124 | + }) |
| 125 | +}) |
| 126 | + |
| 127 | +autoplayAllCheckbox.addEventListener("change", () => { |
| 128 | + const videos = document.querySelectorAll("video") |
| 129 | + videos.forEach((video) => { |
| 130 | + if (autoplayAllCheckbox.checked) { |
| 131 | + video.play() |
| 132 | + } else { |
| 133 | + video.pause() |
| 134 | + } |
| 135 | + }) |
| 136 | +}) |
| 137 | + |
| 138 | +initializeGrid() |
| 139 | + |
0 commit comments