From 16df5bc255f37530b5a0c841cba8f698c4421e6a Mon Sep 17 00:00:00 2001 From: Fluffy-Bean Date: Sat, 22 Apr 2023 10:29:57 +0000 Subject: [PATCH] Optimise loading and reduce image size --- onlylegs/static/js/index.js | 8 +++++--- onlylegs/static/sass/animations.sass | 10 +++++++++- onlylegs/static/sass/components/gallery.sass | 13 ------------- onlylegs/templates/group.html | 15 +++++++++++++-- onlylegs/templates/image.html | 9 +++++++-- onlylegs/templates/index.html | 9 ++++++++- onlylegs/templates/list.html | 9 ++++++++- onlylegs/templates/profile.html | 9 ++++++++- onlylegs/utils/generate_image.py | 2 +- 9 files changed, 59 insertions(+), 25 deletions(-) diff --git a/onlylegs/static/js/index.js b/onlylegs/static/js/index.js index d9d0aa5..8ce7f6d 100644 --- a/onlylegs/static/js/index.js +++ b/onlylegs/static/js/index.js @@ -1,7 +1,9 @@ // fade in images -function imgFade(obj, time = 250) { - obj.style.transition = `opacity ${time}ms`; - obj.style.opacity = 1; +function imgFade(obj, time = 200) { + obj.style.opacity = null; + obj.style.animation = `imgFadeIn ${time}ms`; + + setTimeout(() => { obj.style.animation = null; }, time); } // Lazy load images when they are in view function loadOnView() { diff --git a/onlylegs/static/sass/animations.sass b/onlylegs/static/sass/animations.sass index 9fc623e..d85be1b 100644 --- a/onlylegs/static/sass/animations.sass +++ b/onlylegs/static/sass/animations.sass @@ -8,4 +8,12 @@ 0% left: -100% 100% - left: 100% \ No newline at end of file + left: 100% + +@keyframes imgFadeIn + 0% + opacity: 0 + // filter: blur(0.5rem) + 100% + opacity: 1 + // filter: blur(0) diff --git a/onlylegs/static/sass/components/gallery.sass b/onlylegs/static/sass/components/gallery.sass index 9b980ce..cd33fdd 100644 --- a/onlylegs/static/sass/components/gallery.sass +++ b/onlylegs/static/sass/components/gallery.sass @@ -88,15 +88,8 @@ object-position: center background-color: RGB($bg-bright) - filter: blur(0.5rem) - opacity: 0 - transition: all 0.2s cubic-bezier(.79, .14, .15, .86) - &.loaded - filter: blur(0) - opacity: 1 - &:after content: "" display: block @@ -187,15 +180,9 @@ background-color: RGB($bg-bright) border-radius: $rad-inner box-shadow: 0 0 0.4rem 0.25rem RGBA($bg-100, 0.1) - filter: blur(0.5rem) - opacity: 0 transition: all 0.2s cubic-bezier(.79, .14, .15, .86) - &.loaded - filter: blur(0) - opacity: 1 - &.size-1 .data-1 transform: scale(0.8) rotate(3deg) diff --git a/onlylegs/templates/group.html b/onlylegs/templates/group.html index 50b3474..3a5b651 100644 --- a/onlylegs/templates/group.html +++ b/onlylegs/templates/group.html @@ -224,7 +224,12 @@ {% block content %} {% if images %}