ImagePreview Fixes (#64)

This commit is contained in:
Creation's 2024-10-18 22:12:30 -04:00 committed by GitHub
parent 45002e2ad7
commit 82cae8c771
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 13 additions and 7 deletions

View file

@ -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);
}
});

View file

@ -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",

View file

@ -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;
}
}