From bd6cb65cfcd8568dbdfd7ab8e987191d796e2c36 Mon Sep 17 00:00:00 2001 From: Monica Mateiu Date: Tue, 7 Mar 2023 13:26:34 +0000 Subject: [PATCH 1/5] add animation to Image banner and Image with text --- assets/animations.js | 4 ++-- assets/base.css | 23 +++++++++++++++++++++++ assets/section-image-banner.css | 17 +++++++++++++++++ sections/image-banner.liquid | 10 +++++----- sections/image-with-text.liquid | 2 +- 5 files changed, 48 insertions(+), 8 deletions(-) diff --git a/assets/animations.js b/assets/animations.js index c829263bf19..b5e5e394119 100644 --- a/assets/animations.js +++ b/assets/animations.js @@ -1,5 +1,5 @@ -const SCROLL_ANIMATION_TRIGGER_CLASSNAME = 'scroll-animation__trigger'; -const SCROLL_ANIMATION_ACTIVE_CLASSNAME = 'scroll-animation__trigger--active'; +const SCROLL_ANIMATION_TRIGGER_CLASSNAME = 'scroll-trigger'; +const SCROLL_ANIMATION_ACTIVE_CLASSNAME = 'scroll-trigger--active'; function onIntersection(elements, observer) { elements.forEach((element) => { diff --git a/assets/base.css b/assets/base.css index 1771a2c0c86..0c07a4e56e1 100644 --- a/assets/base.css +++ b/assets/base.css @@ -3134,4 +3134,27 @@ details-disclosure > details { 0% { transform: rotate(0deg) translateX(1em) rotate(0deg) scale(1.2); } 100% { transform: rotate(360deg) translateX(1em) rotate(-360deg) scale(1.2); } } + + .scroll-trigger--active.animate--slide-in { + animation: slideIn var(--duration-long) ease-out forwards; + transition: opacity var(--duration-long) ease-out; + opacity: 0; + } + + /* Turn off animations if JS is turned off. */ + .no-js .scroll-trigger--active { + opacity: 1; + animation: none; + } + + @keyframes slideIn { + from { + transform: translateY(10vh); + opacity: 0; + } + to { + transform: translateY(0); + opacity: 1; + } + } } diff --git a/assets/section-image-banner.css b/assets/section-image-banner.css index a768047d5a3..432540fa696 100644 --- a/assets/section-image-banner.css +++ b/assets/section-image-banner.css @@ -452,3 +452,20 @@ color: currentColor; } } + +.banner.scroll-trigger--active, +.banner.animate--slide-in { + opacity: 1; + animation: none; +} + +.banner__media.scroll-trigger--active, +.banner.scroll-trigger--active:after { + transition: opacity var(--duration-long) ease-out; +} + +.banner__media.animate--slide-in, +.banner.animate--slide-in:after { + animation: none; + opacity: 1; +} diff --git a/sections/image-banner.liquid b/sections/image-banner.liquid index d79d28ee37f..0f83fe1b8dc 100644 --- a/sections/image-banner.liquid +++ b/sections/image-banner.liquid @@ -45,10 +45,10 @@