From 181196149aea0b652ee938aaff7e1c0c217f0a2e Mon Sep 17 00:00:00 2001 From: windingwind <33902321+windingwind@users.noreply.github.com> Date: Sat, 31 Aug 2024 14:10:23 +0800 Subject: [PATCH] Use dynamic max height for attachment preview (#4651) --- chrome/content/zotero/elements/attachmentPreview.js | 1 + scss/elements/_attachmentPreview.scss | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/elements/attachmentPreview.js b/chrome/content/zotero/elements/attachmentPreview.js index 58c50ab225..fc7243e9a6 100644 --- a/chrome/content/zotero/elements/attachmentPreview.js +++ b/chrome/content/zotero/elements/attachmentPreview.js @@ -606,6 +606,7 @@ _handleResize() { if (this.disableResize) return; this.style.setProperty("--preview-width", `${this.clientWidth}px`); + this.style.setProperty("--screen-height", `${window.screen.availHeight}px`); } _handleDragStart(event) { diff --git a/scss/elements/_attachmentPreview.scss b/scss/elements/_attachmentPreview.scss index 2781ea89a2..8258752c04 100644 --- a/scss/elements/_attachmentPreview.scss +++ b/scss/elements/_attachmentPreview.scss @@ -9,7 +9,10 @@ attachment-preview { // Suppose it's A4 size --width-height-ratio: 0.7070707071; --min-height: 56px; - --max-height: 600px; + // This is set in JS + --screen-height: 600px; + // Use screen available height - 200px (approximately the height of the toolbars) + --max-height: calc(max(var(--screen-height) - 200px, 600px)); // This is set in JS --preview-width: 400; --preview-height: calc(min(var(--preview-width) / var(--width-height-ratio), var(--max-height)));