image-carousel.024943eec9daaabea9ff.bundle.js (5835B)
1 /*! elementor - v3.4.4 - 13-09-2021 */ 2 (self["webpackChunkelementor"] = self["webpackChunkelementor"] || []).push([["image-carousel"],{ 3 4 /***/ "../assets/dev/js/frontend/handlers/image-carousel.js": 5 /*!************************************************************!*\ 6 !*** ../assets/dev/js/frontend/handlers/image-carousel.js ***! 7 \************************************************************/ 8 /***/ ((__unused_webpack_module, exports) => { 9 10 "use strict"; 11 12 13 Object.defineProperty(exports, "__esModule", ({ 14 value: true 15 })); 16 exports.default = void 0; 17 18 class ImageCarousel extends elementorModules.frontend.handlers.SwiperBase { 19 getDefaultSettings() { 20 return { 21 selectors: { 22 carousel: '.elementor-image-carousel-wrapper', 23 slideContent: '.swiper-slide' 24 } 25 }; 26 } 27 28 getDefaultElements() { 29 const selectors = this.getSettings('selectors'); 30 const elements = { 31 $swiperContainer: this.$element.find(selectors.carousel) 32 }; 33 elements.$slides = elements.$swiperContainer.find(selectors.slideContent); 34 return elements; 35 } 36 37 getSwiperSettings() { 38 const elementSettings = this.getElementSettings(), 39 slidesToShow = +elementSettings.slides_to_show || 3, 40 isSingleSlide = 1 === slidesToShow, 41 elementorBreakpoints = elementorFrontend.config.responsive.activeBreakpoints, 42 defaultSlidesToShowMap = { 43 mobile: 1, 44 tablet: isSingleSlide ? 1 : 2 45 }; 46 const swiperOptions = { 47 slidesPerView: slidesToShow, 48 loop: 'yes' === elementSettings.infinite, 49 speed: elementSettings.speed, 50 handleElementorBreakpoints: true 51 }; 52 swiperOptions.breakpoints = {}; 53 let lastBreakpointSlidesToShowValue = slidesToShow; 54 Object.keys(elementorBreakpoints).reverse().forEach(breakpointName => { 55 // Tablet has a specific default `slides_to_show`. 56 const defaultSlidesToShow = defaultSlidesToShowMap[breakpointName] ? defaultSlidesToShowMap[breakpointName] : lastBreakpointSlidesToShowValue; 57 swiperOptions.breakpoints[elementorBreakpoints[breakpointName].value] = { 58 slidesPerView: +elementSettings['slides_to_show_' + breakpointName] || defaultSlidesToShow, 59 slidesPerGroup: +elementSettings['slides_to_scroll_' + breakpointName] || 1 60 }; 61 lastBreakpointSlidesToShowValue = +elementSettings['slides_to_show_' + breakpointName] || defaultSlidesToShow; 62 }); 63 64 if ('yes' === elementSettings.autoplay) { 65 swiperOptions.autoplay = { 66 delay: elementSettings.autoplay_speed, 67 disableOnInteraction: 'yes' === elementSettings.pause_on_interaction 68 }; 69 } 70 71 if (isSingleSlide) { 72 swiperOptions.effect = elementSettings.effect; 73 74 if ('fade' === elementSettings.effect) { 75 swiperOptions.fadeEffect = { 76 crossFade: true 77 }; 78 } 79 } else { 80 swiperOptions.slidesPerGroup = +elementSettings.slides_to_scroll || 1; 81 } 82 83 if (elementSettings.image_spacing_custom) { 84 swiperOptions.spaceBetween = elementSettings.image_spacing_custom.size; 85 } 86 87 const showArrows = 'arrows' === elementSettings.navigation || 'both' === elementSettings.navigation, 88 showDots = 'dots' === elementSettings.navigation || 'both' === elementSettings.navigation; 89 90 if (showArrows) { 91 swiperOptions.navigation = { 92 prevEl: '.elementor-swiper-button-prev', 93 nextEl: '.elementor-swiper-button-next' 94 }; 95 } 96 97 if (showDots) { 98 swiperOptions.pagination = { 99 el: '.swiper-pagination', 100 type: 'bullets', 101 clickable: true 102 }; 103 } 104 105 return swiperOptions; 106 } 107 108 async onInit(...args) { 109 super.onInit(...args); 110 const elementSettings = this.getElementSettings(); 111 112 if (!this.elements.$swiperContainer.length || 2 > this.elements.$slides.length) { 113 return; 114 } 115 116 const Swiper = elementorFrontend.utils.swiper; 117 this.swiper = await new Swiper(this.elements.$swiperContainer, this.getSwiperSettings()); // Expose the swiper instance in the frontend 118 119 this.elements.$swiperContainer.data('swiper', this.swiper); 120 121 if ('yes' === elementSettings.pause_on_hover) { 122 this.togglePauseOnHover(true); 123 } 124 } 125 126 updateSwiperOption(propertyName) { 127 const elementSettings = this.getElementSettings(), 128 newSettingValue = elementSettings[propertyName], 129 params = this.swiper.params; // Handle special cases where the value to update is not the value that the Swiper library accepts. 130 131 switch (propertyName) { 132 case 'image_spacing_custom': 133 params.spaceBetween = newSettingValue.size || 0; 134 break; 135 136 case 'autoplay_speed': 137 params.autoplay.delay = newSettingValue; 138 break; 139 140 case 'speed': 141 params.speed = newSettingValue; 142 break; 143 } 144 145 this.swiper.update(); 146 } 147 148 getChangeableProperties() { 149 return { 150 pause_on_hover: 'pauseOnHover', 151 autoplay_speed: 'delay', 152 speed: 'speed', 153 image_spacing_custom: 'spaceBetween' 154 }; 155 } 156 157 onElementChange(propertyName) { 158 const changeableProperties = this.getChangeableProperties(); 159 160 if (changeableProperties[propertyName]) { 161 // 'pause_on_hover' is implemented by the handler with event listeners, not the Swiper library. 162 if ('pause_on_hover' === propertyName) { 163 const newSettingValue = this.getElementSettings('pause_on_hover'); 164 this.togglePauseOnHover('yes' === newSettingValue); 165 } else { 166 this.updateSwiperOption(propertyName); 167 } 168 } 169 } 170 171 onEditSettingsChange(propertyName) { 172 if ('activeItemIndex' === propertyName) { 173 this.swiper.slideToLoop(this.getEditSettings('activeItemIndex') - 1); 174 } 175 } 176 177 } 178 179 exports.default = ImageCarousel; 180 181 /***/ }) 182 183 }]); 184 //# sourceMappingURL=image-carousel.024943eec9daaabea9ff.bundle.js.map