From 7fa067063cb90d7d1a6356eeede5d28472f86688 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DNyymix=E2=80=9D?= Date: Sat, 26 Apr 2025 20:49:10 +0300 Subject: [PATCH] Optimize parallax --- .../templates/gallery/partials/parallax.html | 27 +++++++++++-------- static/css/muistox.css | 10 +++++++ 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/gallery/templates/gallery/partials/parallax.html b/gallery/templates/gallery/partials/parallax.html index 5634298..99b7196 100644 --- a/gallery/templates/gallery/partials/parallax.html +++ b/gallery/templates/gallery/partials/parallax.html @@ -1,26 +1,31 @@ {% load top_tags %} {% load static %} -
+
    {% random_photos_landscape as top_photos %} {% if top_photos %} {% for photo in top_photos %}
  • - Foto from {{ photo.album.name }} album + {% if forloop.first %} loading="eager" decoding="async" {% else %} loading="lazy" decoding="async" {% endif %} + uk-cover + class="lazyfade" + /> + {% endwith %}
  • {% endfor %} {% else %} @@ -28,7 +33,7 @@ Placeholder + alt="Placeholder" uk-cover class="lazyfade" /> {% endif %}
diff --git a/static/css/muistox.css b/static/css/muistox.css index 634fc49..ca17eea 100644 --- a/static/css/muistox.css +++ b/static/css/muistox.css @@ -37,4 +37,14 @@ body { opacity: 1; transform: scale(1); } +} + +.lazyfade { + opacity: 0; + transition: opacity 1s ease; +} + +.lazyfade[loading="eager"], +.lazyfade[loading="lazy"]:not([src=""]) { + opacity: 1; } \ No newline at end of file