forked from Shopify/dawn
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main'
* upstream/main: (205 commits) Fix for small screens with large fonts don't fit all content (Shopify#2946) Adjust quantity rules margin (Shopify#2948) Update Social media settings defaults to remove Shopify links (Shopify#2830) added json to barcode to pass gtin as a json string (Shopify#2804) Fixed extra margin spacing in collage section when header is empty (Shopify#2770) Track state of mouseenter event (Shopify#2934) Fix misalignment of total items in quick order list (Shopify#2923) Hide vol pricing and qty rules when variant is unavailable (Shopify#2889) Fix font family for quick order list (Shopify#2888) v11.0.0 version bump and release notes (Shopify#2916) Revert "v11.0.0 version bump and release notes (Shopify#2906)" (Shopify#2915) Update quantity-popover.css v11.0.0 version bump and release notes (Shopify#2906) Fix social list styles loading (Shopify#2900) Fix an error (Shopify#2903) Fix hardcoded info color (Shopify#2893) Fix error misalignment for Quick order list (Shopify#2887) Replace generic section name with section ID. (Shopify#2884) Fix cart drawer for variant list and tablet spacing (Shopify#2880) Add missing shadow styles to inputs in Quick Order List (Shopify#2879) ...
- Loading branch information
Showing
230 changed files
with
23,271 additions
and
7,985 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"printWidth": 120, | ||
"singleQuote": true, | ||
"overrides": [ | ||
{ | ||
"files": "*.liquid", | ||
"options": { | ||
"singleQuote": false | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"recommendations": ["shopify.theme-check-vscode"] | ||
"recommendations": ["shopify.theme-check-vscode", "esbenp.prettier-vscode"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"editor.formatOnSave": false, | ||
"[javascript]": { | ||
"editor.formatOnSave": true | ||
}, | ||
"[css]": { | ||
"editor.formatOnSave": true | ||
}, | ||
"[liquid]": { | ||
"editor.formatOnSave": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
const SCROLL_ANIMATION_TRIGGER_CLASSNAME = 'scroll-trigger'; | ||
const SCROLL_ANIMATION_OFFSCREEN_CLASSNAME = 'scroll-trigger--offscreen'; | ||
const SCROLL_ZOOM_IN_TRIGGER_CLASSNAME = 'animate--zoom-in'; | ||
const SCROLL_ANIMATION_CANCEL_CLASSNAME = 'scroll-trigger--cancel'; | ||
|
||
// Scroll in animation logic | ||
function onIntersection(elements, observer) { | ||
elements.forEach((element, index) => { | ||
if (element.isIntersecting) { | ||
const elementTarget = element.target; | ||
if (elementTarget.classList.contains(SCROLL_ANIMATION_OFFSCREEN_CLASSNAME)) { | ||
elementTarget.classList.remove(SCROLL_ANIMATION_OFFSCREEN_CLASSNAME); | ||
if (elementTarget.hasAttribute('data-cascade')) | ||
elementTarget.setAttribute('style', `--animation-order: ${index};`); | ||
} | ||
observer.unobserve(elementTarget); | ||
} else { | ||
element.target.classList.add(SCROLL_ANIMATION_OFFSCREEN_CLASSNAME); | ||
element.target.classList.remove(SCROLL_ANIMATION_CANCEL_CLASSNAME); | ||
} | ||
}); | ||
} | ||
|
||
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, { | ||
rootMargin: '0px 0px -50px 0px', | ||
}); | ||
animationTriggerElements.forEach((element) => observer.observe(element)); | ||
} | ||
|
||
// Zoom in animation logic | ||
function initializeScrollZoomAnimationTrigger() { | ||
if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) return; | ||
|
||
const animationTriggerElements = Array.from(document.getElementsByClassName(SCROLL_ZOOM_IN_TRIGGER_CLASSNAME)); | ||
|
||
if (animationTriggerElements.length === 0) return; | ||
|
||
const scaleAmount = 0.2 / 100; | ||
|
||
animationTriggerElements.forEach((element) => { | ||
let elementIsVisible = false; | ||
const observer = new IntersectionObserver((elements) => { | ||
elements.forEach((entry) => { | ||
elementIsVisible = entry.isIntersecting; | ||
}); | ||
}); | ||
observer.observe(element); | ||
|
||
element.style.setProperty('--zoom-in-ratio', 1 + scaleAmount * percentageSeen(element)); | ||
|
||
window.addEventListener( | ||
'scroll', | ||
throttle(() => { | ||
if (!elementIsVisible) return; | ||
|
||
element.style.setProperty('--zoom-in-ratio', 1 + scaleAmount * percentageSeen(element)); | ||
}), | ||
{ passive: true } | ||
); | ||
}); | ||
} | ||
|
||
function percentageSeen(element) { | ||
const viewportHeight = window.innerHeight; | ||
const scrollY = window.scrollY; | ||
const elementPositionY = element.getBoundingClientRect().top + scrollY; | ||
const elementHeight = element.offsetHeight; | ||
|
||
if (elementPositionY > scrollY + viewportHeight) { | ||
// If we haven't reached the image yet | ||
return 0; | ||
} else if (elementPositionY + elementHeight < scrollY) { | ||
// If we've completely scrolled past the image | ||
return 100; | ||
} | ||
|
||
// When the image is in the viewport | ||
const distance = scrollY + viewportHeight - elementPositionY; | ||
let percentage = distance / ((viewportHeight + elementHeight) / 100); | ||
return Math.round(percentage); | ||
} | ||
|
||
window.addEventListener('DOMContentLoaded', () => { | ||
initializeScrollAnimationTrigger(); | ||
initializeScrollZoomAnimationTrigger(); | ||
}); | ||
|
||
if (Shopify.designMode) { | ||
document.addEventListener('shopify:section:load', (event) => initializeScrollAnimationTrigger(event.target, true)); | ||
document.addEventListener('shopify:section:reorder', () => initializeScrollAnimationTrigger(document, true)); | ||
} |
Oops, something went wrong.