PageSourceSearch

https://carnivorebar.com/cdn/shop/t/51/assets/paginated-list-aspect-ratio.js?v=25254270272143792451789412949

js carnivorebar.com collected 2026-09-24 18:06:30 UTC 2,617 bytes, 2 lines download raw bytes

1export class PaginatedListAspectRatioHelper{#imageRatioSetting=null;#ASPECT_RATIOS={square:"1",portrait:"0.8",landscape:"1.778"};constructor({templateCard}){Shopify.designMode&&this.#storeImageRatioSettings(templateCard)}processNewElements(){Shopify.designMode&&requestAnimationFrame(()=>{this.#imageRatioSetting==="adapt"?this.#fixAdaptiveAspectRatios():this.#applyFixedAspectRatio()})}#storeImageRatioSettings(templateCard){this.#imageRatioSetting=templateCard.getAttribute("data-image-ratio")}#fixAdaptiveAspectRatios(){const newCardGalleries=this.#getUnprocessedGalleries();if(!newCardGalleries.length)return;const productRatioCache=new Map;newCardGalleries.forEach(gallery=>{if(!(gallery instanceof HTMLElement))return;const productId=gallery.getAttribute("data-product-id");if(productId&&productRatioCache.has(productId)){this.#applyAspectRatioToGallery(gallery,productRatioCache.get(productId));return}const img=gallery.querySelector("img");if(!img){this.#applyAspectRatioToGallery(gallery,"1");return}const loadAndSetRatio=()=>{if(!img.naturalWidth||!img.naturalHeight)return;const imgRatio=this.#getSafeImageAspectRatio(img.naturalWidth,img.naturalHeight);
1productId&&productRatioCache.set(productId,imgRatio),this.#applyAspectRatioToGallery(gallery,imgRatio)};img.complete?loadAndSetRatio():img.addEventListener("load",loadAndSetRatio,{once:!0})})}#applyFixedAspectRatio(){if(!this.#imageRatioSetting)return;const aspectRatio=this.#getAspectRatioValue(this.#imageRatioSetting);if(!aspectRatio)return;const newCardGalleries=this.#getUnprocessedGalleries();newCardGalleries.length&&requestAnimationFrame(()=>{newCardGalleries.forEach(gallery=>{gallery instanceof HTMLElement&&this.#applyAspectRatioToGallery(gallery,aspectRatio)})})}#getSafeImageAspectRatio(width,height){const rawRatio=width/height;return Math.max(.1,Math.min(10,rawRatio)).toFixed(3)}#getAspectRatioValue(ratioSetting){return this.#ASPECT_RATIOS[ratioSetting]||null}#applyAspectRatioToGallery(gallery,aspectRatio){if(!(gallery instanceof HTMLElement))return;gallery.style.setProperty("--gallery-aspect-ratio",aspectRatio),gallery.querySelectorAll(".product-media-container").forEach(container=>{container instanceof HTMLElement&&(container.style.aspectRatio=aspectRatio)}),this.#markAsProcessed(gallery)}#getUnprocessedGalleries(){return document.querySelectorAll(".card-gallery:not([data-aspect-ratio-applied])")}#markAsProcessed(gallery){gallery instanceof HTMLElement&&gallery.setAttribute("data-aspect-ratio-applied","true")}}
2//# sourceMappingURL=/cdn/shop/t/51/assets/paginated-list-aspect-ratio.js.map?v=25254270272143792451789412949

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.