PageSourceSearch

https://www.vistra.com/themes/custom/vistra2024/js/carousel-nav-buttons.js?tlu1y1

js vistra.com collected 2026-09-24 18:12:54 UTC 1,949 bytes, 54 lines download raw bytes

1(function ($, Drupal, once) {
2  'use strict';
3
4  /**
5   * Carousel scroll buttons
6   */
7  Drupal.behaviors.carouselScrollButtons = {
8    attach: function (context, settings) {
9      // Grab all new carousel containers that haven't been processed yet
10      const elements = once('carouselScrollButtons', '.carouselContainer', context);
11
12      if (elements.length) {
13        const duration = 330;
14
15        // Loop through each carousel instance individually
16        $(elements).each(function () {
17          const $container = $(this);
18          const $slider = $container.find('.carouselSlider');
19
20          // Initial state for THIS specific container
21          $container.find('.slideBack').prop('disabled', true);
22
23          // 1. Scroll Event (Handles trackpad, swipe, AND animation scrolling)
24          $slider.on('scroll', function () {
25            const scrollLeft = $slider.scrollLeft();
26            const scrollWidth = $slider[0].scrollWidth;
27            const containerWidth = $slider.outerWidth();
28
29            $container.find('.slideBack').prop('disabled', scrollLeft <= 0);
30            $container.find('.slideForward').prop('disabled', scrollLeft + containerWidth >= scrollWidth - 1);
31          });
32
33          // 2. Click Events
34          $container.find('.slideForward').click(function () {
35            // We pass $container to getScrollDistance to measure the correct cards
36            $slider.animate({ scrollLeft: '+=' + getScrollDistance($container) }, duration);
37          });
38
39          $container.find('.slideBack').click(function () {
40            $slider.animate({ scrollLeft: '-=' + getScrollDistance($container) }, duration);
41          });
42        });
43      }
44    }
45  };
46
47  // Helper function scoped to the specific container
48  function getScrollDistance($container) {
49    const elementWidth = $container.find('.carouselElement').width();
50    const margin = 16;
51    return elementWidth + margin;
52  }
53
54})(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.