페이지 정보
작성자
🥷관리자
작성일 25-09-29 05:44
document.addEventListener("DOMContentLoaded", function() {
document.querySelectorAll(".gall_image[data-src]").forEach(function(box) {
const videoUrl = box.dataset.src;
const icon = box.querySelector(".play-icon");
let videoEl = null;
box.addEventListener("mouseenter", function() {
if (!videoEl) {
videoEl = document.createElement("video");
videoEl.src = videoUrl;
videoEl.autoplay = true;
videoEl.muted = true;
videoEl.loop = true;
videoEl.playsInline = true;
videoEl.style.position = "absolute";
videoEl.style.top = 0;
videoEl.style.left = 0;
videoEl.style.width = "100%";
videoEl.style.height = "100%";
videoEl.style.objectFit = "cover";
box.appendChild(videoEl);
if (icon) icon.style.display = "none";
}
});
box.addEventListener("mouseleave", function() {
if (videoEl) {
videoEl.remove();
videoEl = null;
if (icon) icon.style.display = "block";
}
});
});
});