mirror of
https://github.com/yv1ing/MollyBlog.git
synced 2025-09-16 14:53:45 +08:00
new: Add article image preview function
This commit is contained in:
@@ -52,4 +52,24 @@ function backToTop() {
|
||||
top: 0,
|
||||
behavior: 'smooth'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// image preview
|
||||
const contentImages = document.querySelectorAll("#post-content img");
|
||||
contentImages.forEach((img) => {
|
||||
img.style.cursor = "pointer";
|
||||
img.addEventListener("click", () => {
|
||||
openPreview(img);
|
||||
})
|
||||
});
|
||||
|
||||
function openPreview(img) {
|
||||
const src = img.getAttribute("src");
|
||||
|
||||
document.getElementById("image-preview-img").setAttribute("src", src);
|
||||
document.getElementById("image-preview-wrap").style.display = "flex";
|
||||
}
|
||||
|
||||
function closePreview() {
|
||||
document.getElementById("image-preview-wrap").style.display = "none";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user