1(function ($) { 2 'use strict'; 3 4 var VISIBLE = 4; 5 6 function initGalleryBeds() { 7 var $sliders = $('.digi-gallery-beds .gallery-beds-slider'); 8 if (!$sliders.length) return; 9 10 $sliders.each(function () { 11 var $slider = $(this); 12 var $track = $slider.find('.gallery-beds-slider__track'); 13 var $items = $slider.find('.gallery-beds-slider__item'); 14 var total = $items.length; 15 var current = 0; 16 17 function getVisible() { 18 var w = $slider.width(); 19 if (w < 640) return 1; 20 if (w < 1024) return 2; 21 return VISIBLE; 22 } 23 24 function updateSlider() { 25 var vis = getVisible(); 26 var maxIdx = Math.max(0, total - vis); 27 if (current > maxIdx) current = maxIdx; 28 29 var itemW = $slider.find('.gallery-beds-slider__viewport').width() / vis; 30 var offset = -(current * itemW); 31 32 $items.css('width', itemW + 'px'); 33 $track.css('transform', 'translateX(' + offset + 'px)'); 34 35 $slider.find('.gallery-beds-slider__prev').toggleClass('is-hidden', current <= 0); 36 $slider.find('.gallery-beds-slider__next').toggleClass('is-hidden', current >= maxIdx); 37 } 38 39 $slider.find('.js-gb-prev').on('click', function () { 40 if (current > 0) { current--; updateSlider(); } 41 }); 42 43 $slider.find('.js-gb-next').on('click', function () { 44 var maxIdx = Math.max(0, total - getVisible()); 45 if (current < maxIdx) { current++; updateSlider(); } 46 }); 47 48 updateSlider(); 49 $(window).on('resize.gbSlider', updateSlider); 50 }); 51 } 52 53 $(document).ready(initGalleryBeds); 54 55}(jQuery));
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.