From 935e898ae67b114d11b4b28cabd138b9c05e5c70 Mon Sep 17 00:00:00 2001 From: Monica Mateiu Date: Tue, 7 Mar 2023 13:26:34 +0000 Subject: [PATCH] add animation to Image banner and Image with text --- assets/base.css | 57 +++++++++++++++++++++++++++++++++ sections/image-banner.liquid | 17 ++++++---- sections/image-with-text.liquid | 2 +- 3 files changed, 69 insertions(+), 7 deletions(-) diff --git a/assets/base.css b/assets/base.css index b1fe858562b..ea5ebe23d63 100644 --- a/assets/base.css +++ b/assets/base.css @@ -3120,3 +3120,60 @@ details-disclosure > details { .rte blockquote > * { margin: -0.5rem 0 -0.5rem 0; } + +/* Animations */ + +.scroll-animation__trigger { + transition: opacity 0.55s ease-in-out; + opacity: 0; +} + +.scroll-animation__trigger--active { + animation: 0.55s ease-in-out slideIn forwards; +} + +@keyframes slideIn { + from { + transform: translateY(10vh); + opacity: 0; + } + to { + transform: translateY(0); + opacity: 1; + } +} + +/* Section-specific motion behavior. */ + +.banner.scroll-animation__trigger, +.banner.scroll-animation__trigger--active { + opacity: 1; + animation: none; +} + +.banner__media.scroll-animation__trigger, +.banner.scroll-animation__trigger:after { + transition: opacity var(--duration-long) ease-in-out; +} + +.banner__media.scroll-animation__trigger--active, +.banner.scroll-animation__trigger--active:after { + animation: none; + opacity: 1; +} + +/* Turn off animations if JS is turned off. */ +.no-js .scroll-animation__trigger, +.no-js .scroll-animation__trigger--active { + opacity: 1; + animation: none; +} + +/* Respect the visitor's motion preferences. */ +@media (prefers-reduced-motion) { + .scroll-animation__trigger, + .scroll-animation__trigger--active { + opacity: 1; + animation: none; + } +} diff --git a/sections/image-banner.liquid b/sections/image-banner.liquid index 716cd15fa89..668094e89c2 100644 --- a/sections/image-banner.liquid +++ b/sections/image-banner.liquid @@ -24,17 +24,22 @@ {%- endif -%} {%- style -%} - #Banner-{{ section.id }}::after { + #Banner-{{ section.id }}.scroll-animation__trigger::after { + opacity: 0; + } + + #Banner-{{ section.id }}::after, + #Banner-{{ section.id }}.scroll-animation__trigger--active::after { opacity: {{ section.settings.image_overlay_opacity | divided_by: 100.0 }}; } {%- endstyle -%}