Skip to content

Commit 443d3ad

Browse files
committed
bug: fix image and pdf link functions
1 parent e7a7060 commit 443d3ad

3 files changed

Lines changed: 28 additions & 6 deletions

File tree

assets/css/lightbox.css

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,19 @@
2727
max-width: 90%;
2828
max-height: 90vh;
2929
object-fit: contain;
30-
box-shadow: 0 0 20px rgba(0,0,0,0.5);
30+
box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
3131
animation-name: zoom;
3232
animation-duration: 0.3s;
3333
}
3434

3535
@keyframes zoom {
36-
from {transform:scale(0)}
37-
to {transform:scale(1)}
36+
from {
37+
transform: scale(0)
38+
}
39+
40+
to {
41+
transform: scale(1)
42+
}
3843
}
3944

4045
/* Close Button */
@@ -62,8 +67,12 @@
6267
.lightbox-image {
6368
cursor: zoom-in;
6469
transition: opacity 0.2s;
70+
/* Ensure image fits within its container */
71+
display: block;
72+
max-width: 100%;
73+
height: auto;
6574
}
6675

6776
.lightbox-image:hover {
6877
opacity: 0.9;
69-
}
78+
}

assets/js/pdf-slide.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class PdfSlideViewer {
7777
// Window resize
7878
window.addEventListener('resize', () => {
7979
if (this.modal.classList.contains('active')) {
80-
this.renderPage(this.pageNum);
80+
this.queueRenderPage(this.pageNum);
8181
}
8282
});
8383
}
@@ -173,7 +173,7 @@ class PdfSlideViewer {
173173
} else {
174174
// PDF already loaded (e.g. by renderPreview), but we need to ensure UI is synced
175175
this.pageCountDom.textContent = this.pdfDoc.numPages;
176-
this.renderPage(this.pageNum);
176+
this.queueRenderPage(this.pageNum);
177177
this.hideSpinner();
178178
}
179179
}
@@ -210,11 +210,20 @@ class PdfSlideViewer {
210210
}
211211
}
212212

213+
/**
214+
* Get page info from document, resize canvas accordingly, and render page.
215+
* @param num Page number.
216+
*/
213217
/**
214218
* Get page info from document, resize canvas accordingly, and render page.
215219
* @param num Page number.
216220
*/
217221
async renderPage(num) {
222+
if (this.pageRendering) {
223+
this.pageNumPending = num;
224+
return;
225+
}
226+
218227
this.pageRendering = true;
219228

220229
try {

layouts/_default/_markup/render-image.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55

66
{{- /* Check if it's a local resource to optimize */ -}}
77
{{- if not $u.IsAbs -}}
8+
{{- /* Strip starting ./ or / for resource lookup */ -}}
89
{{- $path := strings.TrimPrefix "./" $u.Path }}
10+
{{- $path := strings.TrimPrefix "/" $path }}
11+
12+
{{- /* Try to find the resource in page bundle or assets */ -}}
913
{{- with or (.Page.Resources.Get $path) (resources.Get $path) -}}
1014
{{- $isLocal = true -}}
1115
{{- /* Resize to a reasonable max width for the page flow, e.g., 1200px */ -}}

0 commit comments

Comments
 (0)