페이지 정보
작성자
🥷관리자
작성일 25-09-29 05:24
document.addEventListener("DOMContentLoaded", function() {
document.querySelectorAll(".gall_image").forEach(function(box) {
const videoUrl = box.dataset.src;
if (!videoUrl) return;
const icon = box.querySelector(".play-icon");
let videoEl = null;
box.addEventListener("mouseenter", function() {
if (!videoEl) {
videoEl = document.createElement("video");
videoEl.src = videoUrl;
videoEl.className = "preview";
videoEl.autoplay = true;
videoEl.muted = true;
videoEl.loop = true;
videoEl.playsInline = true;
videoEl.style.display = "block";
box.appendChild(videoEl);
if (icon) icon.style.opacity = 0;
}
});
box.addEventListener("mouseleave", function() {
if (videoEl) {
videoEl.remove();
videoEl = null;
if (icon) icon.style.opacity = 1;
}
});
});
});