put images in their own lane
This commit is contained in:
@ -142,8 +142,22 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
//lightboxes
|
||||
lightboxObj = constructLightbox();
|
||||
document.body.appendChild(lightboxObj.dialog);
|
||||
const postImages = document.querySelectorAll(".post-inner img.block-img");
|
||||
|
||||
function setImageMaxSize(img) {
|
||||
const { maxWidth: origMaxWidth } = getComputedStyle(img);
|
||||
if (img.naturalWidth >= parseInt(origMaxWidth)) {
|
||||
return;
|
||||
}
|
||||
img.style.maxWidth = img.naturalWidth + "px";
|
||||
}
|
||||
|
||||
const postImages = document.querySelectorAll(".post-inner img.post-image");
|
||||
postImages.forEach(postImage => {
|
||||
if (postImage.complete) {
|
||||
setImageMaxSize(postImage);
|
||||
} else {
|
||||
postImage.addEventListener("load", () => setImageMaxSize(postImage));
|
||||
}
|
||||
const belongingTo = postImage.closest(".post-inner");
|
||||
const images = lightboxImages.get(belongingTo) ?? [];
|
||||
images.push({
|
||||
|
Reference in New Issue
Block a user