aboutsummaryrefslogtreecommitdiff
path: root/static/widgets
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2025-11-24 18:26:20 +0100
committerNathan Reiner <nathan@nathanreiner.xyz>2025-11-24 18:26:20 +0100
commit97b35ce73fab8a84d4d3e6807618a252efcf4cd9 (patch)
tree0f33ce44e380b17a17a8361bc5d99c51b8dd3631 /static/widgets
parentf2cd03729059206fe584e2a9f278dd67625a9221 (diff)
image-viewer: lazy-loader
Diffstat (limited to 'static/widgets')
-rw-r--r--static/widgets/image/index.css6
-rw-r--r--static/widgets/image/index.js7
2 files changed, 11 insertions, 2 deletions
diff --git a/static/widgets/image/index.css b/static/widgets/image/index.css
index 730a324..a53bddc 100644
--- a/static/widgets/image/index.css
+++ b/static/widgets/image/index.css
@@ -5,18 +5,22 @@
border-radius: var(--border-radius);
overflow: none;
box-shadow: #223223aa 1px 1px 4px;
+ background: var(--card-background);
}
#container img {
border-radius: var(--border-radius);
max-width: 700px;
- width: 100%;
+ width: calc(100vw - 20px);
visibility: hidden;
margin-bottom: -5px;
+ height: calc((100vw - 20px) * 0.8);
}
#container.loaded img {
visibility: visible;
+ width: 100%;
+ height: unset;
}
@keyframes loader {
diff --git a/static/widgets/image/index.js b/static/widgets/image/index.js
index 202494b..4c25988 100644
--- a/static/widgets/image/index.js
+++ b/static/widgets/image/index.js
@@ -46,6 +46,11 @@ export default class Image extends sfw.element.Container {
set id(id) {
this.#id = id;
this.#container.classList.remove('loaded');
- this.#image.src = `/api/image/load/${id}`;
+ }
+
+ load() {
+ if (!this.#image.src) {
+ this.#image.src = `/api/image/load/${this.#id}`;
+ }
}
}