mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-13 00:23:02 -04:00
ImagePreview Fixes (#64)
This commit is contained in:
parent
45002e2ad7
commit
82cae8c771
3 changed files with 13 additions and 7 deletions
|
@ -138,11 +138,12 @@ function loadImagePreview(url: string) {
|
||||||
|
|
||||||
const fileName = document.createElement("span");
|
const fileName = document.createElement("span");
|
||||||
const fileSize = document.createElement("span");
|
const fileSize = document.createElement("span");
|
||||||
fileSize.className = "file-size";
|
|
||||||
const fileSizeSpan = document.createElement("p");
|
const fileSizeSpan = document.createElement("p");
|
||||||
const showingSize = document.createElement("p");
|
const showingSize = document.createElement("p");
|
||||||
const mimeTypeSpan = document.createElement("span");
|
const mimeTypeSpan = document.createElement("span");
|
||||||
|
|
||||||
|
fileSize.className = "file-size";
|
||||||
|
|
||||||
const updatePositionAfterLoad = () => {
|
const updatePositionAfterLoad = () => {
|
||||||
if (lastMouseEvent && currentPreview) {
|
if (lastMouseEvent && currentPreview) {
|
||||||
updatePreviewPosition(lastMouseEvent, currentPreview);
|
updatePreviewPosition(lastMouseEvent, currentPreview);
|
||||||
|
@ -242,14 +243,14 @@ function loadImagePreview(url: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.store.mouseOnlyMode) {
|
if (settings.store.mouseOnlyMode) {
|
||||||
currentPreviewFile.addEventListener("mouseover", () => {
|
currentPreview.addEventListener("mouseover", () => {
|
||||||
if (currentPreview && !isCtrlHeld) {
|
if (currentPreview && !isCtrlHeld) {
|
||||||
shouldKeepPreviewOpen = true;
|
shouldKeepPreviewOpen = true;
|
||||||
currentPreview.classList.add("allow-zoom-and-drag");
|
currentPreview.classList.add("allow-zoom-and-drag");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
currentPreviewFile.addEventListener("mouseout", () => {
|
currentPreview.addEventListener("mouseout", () => {
|
||||||
if (currentPreview && !isCtrlHeld && shouldKeepPreviewOpen) {
|
if (currentPreview && !isCtrlHeld && shouldKeepPreviewOpen) {
|
||||||
deleteCurrentPreview();
|
deleteCurrentPreview();
|
||||||
shouldKeepPreviewOpen = false;
|
shouldKeepPreviewOpen = false;
|
||||||
|
@ -376,7 +377,7 @@ function addHoverListener(element: Element) {
|
||||||
|
|
||||||
lastMouseEvent = event as MouseEvent;
|
lastMouseEvent = event as MouseEvent;
|
||||||
|
|
||||||
if (currentPreview && !isCtrlHeld) {
|
if (currentPreview && !isCtrlHeld && !settings.store.fixedImage) {
|
||||||
updatePreviewPosition(lastMouseEvent, element as HTMLElement);
|
updatePreviewPosition(lastMouseEvent, element as HTMLElement);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -38,6 +38,11 @@ const settings = definePluginSettings({
|
||||||
description: "Allows you to skip having to hold control to zoom in and move images",
|
description: "Allows you to skip having to hold control to zoom in and move images",
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
|
fixedImage: {
|
||||||
|
type: OptionType.BOOLEAN,
|
||||||
|
description: "Fixes the image preview to the initial point of hover",
|
||||||
|
default: false
|
||||||
|
},
|
||||||
hoverDelay: {
|
hoverDelay: {
|
||||||
type: OptionType.SLIDER,
|
type: OptionType.SLIDER,
|
||||||
description: "Delay in seconds before the image preview appears",
|
description: "Delay in seconds before the image preview appears",
|
||||||
|
|
|
@ -40,8 +40,8 @@
|
||||||
border: 1px solid var(--background-secondary);
|
border: 1px solid var(--background-secondary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.image-preview .file-info span:last-child:not(:first-child) {
|
.image-preview .file-info span:not(:last-child) {
|
||||||
margin: 0 5px;
|
margin: 0 5px 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.file-size {
|
.file-size {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue