From 82cae8c77174e2cc60687d31ca6b40368edd1e3f Mon Sep 17 00:00:00 2001 From: Creation's Date: Fri, 18 Oct 2024 22:12:30 -0400 Subject: [PATCH] ImagePreview Fixes (#64) --- src/equicordplugins/imagePreview/index.ts | 9 +++++---- src/equicordplugins/imagePreview/settings.ts | 5 +++++ src/equicordplugins/imagePreview/styles.css | 6 +++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/equicordplugins/imagePreview/index.ts b/src/equicordplugins/imagePreview/index.ts index ee12ec60..85352df0 100644 --- a/src/equicordplugins/imagePreview/index.ts +++ b/src/equicordplugins/imagePreview/index.ts @@ -138,11 +138,12 @@ function loadImagePreview(url: string) { const fileName = document.createElement("span"); const fileSize = document.createElement("span"); - fileSize.className = "file-size"; const fileSizeSpan = document.createElement("p"); const showingSize = document.createElement("p"); const mimeTypeSpan = document.createElement("span"); + fileSize.className = "file-size"; + const updatePositionAfterLoad = () => { if (lastMouseEvent && currentPreview) { updatePreviewPosition(lastMouseEvent, currentPreview); @@ -242,14 +243,14 @@ function loadImagePreview(url: string) { } if (settings.store.mouseOnlyMode) { - currentPreviewFile.addEventListener("mouseover", () => { + currentPreview.addEventListener("mouseover", () => { if (currentPreview && !isCtrlHeld) { shouldKeepPreviewOpen = true; currentPreview.classList.add("allow-zoom-and-drag"); } }); - currentPreviewFile.addEventListener("mouseout", () => { + currentPreview.addEventListener("mouseout", () => { if (currentPreview && !isCtrlHeld && shouldKeepPreviewOpen) { deleteCurrentPreview(); shouldKeepPreviewOpen = false; @@ -376,7 +377,7 @@ function addHoverListener(element: Element) { lastMouseEvent = event as MouseEvent; - if (currentPreview && !isCtrlHeld) { + if (currentPreview && !isCtrlHeld && !settings.store.fixedImage) { updatePreviewPosition(lastMouseEvent, element as HTMLElement); } }); diff --git a/src/equicordplugins/imagePreview/settings.ts b/src/equicordplugins/imagePreview/settings.ts index f20d6217..d78f22c0 100644 --- a/src/equicordplugins/imagePreview/settings.ts +++ b/src/equicordplugins/imagePreview/settings.ts @@ -38,6 +38,11 @@ const settings = definePluginSettings({ description: "Allows you to skip having to hold control to zoom in and move images", default: false }, + fixedImage: { + type: OptionType.BOOLEAN, + description: "Fixes the image preview to the initial point of hover", + default: false + }, hoverDelay: { type: OptionType.SLIDER, description: "Delay in seconds before the image preview appears", diff --git a/src/equicordplugins/imagePreview/styles.css b/src/equicordplugins/imagePreview/styles.css index 4e20bd35..c2f91440 100644 --- a/src/equicordplugins/imagePreview/styles.css +++ b/src/equicordplugins/imagePreview/styles.css @@ -40,8 +40,8 @@ border: 1px solid var(--background-secondary); } -.image-preview .file-info span:last-child:not(:first-child) { - margin: 0 5px; +.image-preview .file-info span:not(:last-child) { + margin: 0 5px 0 0; } .file-size { @@ -87,4 +87,4 @@ max-height: 90vh; object-fit: contain; display: none; -} +} \ No newline at end of file