1/** 2 * @file fage-animated-slider.js 3 * Fage Yogurt basic hero for "animated_slider" component. 4 * Functionality copied from 5 * web/themes/custom/fage_yogurt/components/components/basic-hero/basic-hero.js 6 */ 7(function ($, Drupal, once) { 8 "use strict"; 9 10 Drupal.behaviors.fageAnimatedSlider = { 11 attach(context, settings) { 12 13 function addAnimation(scrollers) { 14 scrollers.forEach((scroller) => { 15 // add data-animated="true" to every `.scroller` on the page 16 scroller.setAttribute("data-animated", true); 17 18 // Make an array from the elements within `.scroller-inner` 19 const scrollerInner = scroller.querySelectorAll( 20 ".animated-slider__carousel" 21 ); 22 scrollerInner.forEach((scroller) => { 23 const scrollerContent = Array.from(scroller.children); 24 25 // For each item in the array, clone it 26 // add aria-hidden to it 27 // add it into the `.scroller-inner` 28 scrollerContent.forEach((item) => { 29 const duplicatedItem = item.cloneNode(true); 30 duplicatedItem.setAttribute("aria-hidden", true); 31 if (scroller.classList.contains("carousel-forward")) { 32 scroller.appendChild(duplicatedItem); 33 } else if (scroller.classList.contains("carousel-backward")) { 34 scroller.appendChild(duplicatedItem); 35 } 36 }); 37 }); 38 }); 39 } 40 41 const scrollers = once('fage-animated-slider', '.animated-slider', context); 42 if (scrollers.length) { 43 // If a user hasn't opted in for recuded motion, then we add the animation 44 if (!window.matchMedia("(prefers-reduced-motion: reduce)").matches) { 45 addAnimation(scrollers); 46 } 47 } 48 }, 49 }; 50})(jQuery, Drupal, once);
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.