From ea3fc1943292deaedd7d7412ca1bd35acce111e5 Mon Sep 17 00:00:00 2001 From: Roi-Arthur <48017311+Roi-Arthur@users.noreply.github.com> Date: Wed, 19 Apr 2023 11:31:58 +0100 Subject: [PATCH] Merge branch 'main' into grid-image-blurry-fix (#2545) * [Motion] Use rootMargin instread of threshold to trigger slide in animations (#2517) * Use rootMargin instread of threshold to trigger slide in animations * address review comment, remove threshold * Add conditional around data-cascade attribute (#2532) * [Motion] No animation on added/edited section (#2502) --------- Co-authored-by: Ludo --- assets/animations.js | 16 +++++++++--- assets/base.css | 10 +++++++- sections/collage.liquid | 4 ++- sections/featured-collection.liquid | 15 ++++++++--- sections/main-collection-product-grid.liquid | 15 +++++++++-- sections/multicolumn.liquid | 11 +++++++-- sections/newsletter.liquid | 26 +++++++++++++++++--- sections/rich-text.liquid | 20 ++++++++++++--- 8 files changed, 97 insertions(+), 20 deletions(-) diff --git a/assets/animations.js b/assets/animations.js index e3b560cf9e6..f240e24948d 100644 --- a/assets/animations.js +++ b/assets/animations.js @@ -13,16 +13,26 @@ function onIntersection(elements, observer) { }); } -function initializeScrollAnimationTrigger(rootEl = document) { +function initializeScrollAnimationTrigger(rootEl = document, isDesignModeEvent = false) { const animationTriggerElements = Array.from(rootEl.getElementsByClassName(SCROLL_ANIMATION_TRIGGER_CLASSNAME)); if (animationTriggerElements.length === 0) return; + if (isDesignModeEvent) { + animationTriggerElements.forEach((element) => { + element.classList.add('scroll-trigger--design-mode'); + }); + return; + } + const observer = new IntersectionObserver(onIntersection, { - threshold: 0.1, + rootMargin: '0px 0px -50px 0px', }); animationTriggerElements.forEach((element) => observer.observe(element)); } window.addEventListener('DOMContentLoaded', () => initializeScrollAnimationTrigger()); -document.addEventListener('shopify:section:load', (event) => initializeScrollAnimationTrigger(event.target)); +if (Shopify.designMode) { + document.addEventListener('shopify:section:load', (event) => initializeScrollAnimationTrigger(event.target, true)); + document.addEventListener('shopify:section:reorder', () => initializeScrollAnimationTrigger(document, true)); +} diff --git a/assets/base.css b/assets/base.css index 779890416d5..6a0ddf1f488 100644 --- a/assets/base.css +++ b/assets/base.css @@ -746,7 +746,7 @@ details > * { --duration-default: 200ms; --duration-long: 500ms; --duration-extra-long: 600ms; - --animation-slide-in: slideIn var(--duration-extra-long) cubic-bezier(0,0,.3,1) forwards; + --animation-slide-in: slideIn var(--duration-extra-long) cubic-bezier(0, 0, 0.3, 1) forwards; } .underlined-link, @@ -3292,6 +3292,14 @@ details-disclosure > details { animation-delay: calc(var(--animation-order) * 75ms); } + .scroll-trigger--design-mode.animate--fade-in, + .scroll-trigger--design-mode.animate--slide-in, + .scroll-trigger--design-mode .slider { + opacity: 1; + animation: none; + transition: none; + } + /* Turn off animations if JS is turned off. */ .no-js .scroll-trigger.animate--fade-in, .no-js .scroll-trigger.animate--slide-in { diff --git a/sections/collage.liquid b/sections/collage.liquid index 228e22f731b..536a2e50fb0 100644 --- a/sections/collage.liquid +++ b/sections/collage.liquid @@ -28,7 +28,9 @@
{%- case block.type -%} {%- when 'image' -%} diff --git a/sections/featured-collection.liquid b/sections/featured-collection.liquid index 1e4f82c23b7..d4a14ae038a 100644 --- a/sections/featured-collection.liquid +++ b/sections/featured-collection.liquid @@ -52,7 +52,9 @@
{%- if section.settings.title != blank -%} -

{{ section.settings.title }}

+

+ {{ section.settings.title }} +

{%- endif -%} {%- if section.settings.description != blank or section.settings.show_description @@ -79,7 +81,9 @@
  • {% render 'card-product', columns_desktop: section.settings.columns_desktop, @@ -96,7 +100,12 @@
  • {%- else -%} {%- for i in (1..4) -%} -
  • +
  • {% render 'card-product', show_vendor: section.settings.show_vendor %}
  • {%- endfor -%} diff --git a/sections/main-collection-product-grid.liquid b/sections/main-collection-product-grid.liquid index adb8225d573..2406c0dd7b2 100644 --- a/sections/main-collection-product-grid.liquid +++ b/sections/main-collection-product-grid.liquid @@ -121,7 +121,13 @@ {%- endif -%} -
    +
    {%- if collection.products.size == 0 -%}
    @@ -153,7 +159,12 @@ {%- if forloop.index > 2 -%} {%- assign lazy_load = true -%} {%- endif -%} -
  • +
  • {% render 'card-product', columns_desktop: section.settings.columns_desktop, columns_mobile: section.settings.columns_mobile, diff --git a/sections/multicolumn.liquid b/sections/multicolumn.liquid index f0eedbde0f5..485dea2d412 100644 --- a/sections/multicolumn.liquid +++ b/sections/multicolumn.liquid @@ -24,7 +24,12 @@ -%}
    -
    +
    {%- unless section.settings.title == blank -%}