export default class universalCarousel { constructor(el) { this.el = el; } /** * Description. Add the navigation to carousel. */ addNavigation(ucWrapper) { if ($(ucWrapper).hasClass('uc-nav')) { $(ucWrapper) .find('.swiper-container') .append( '
' ); } } /** * Description. Add the pagination to carousel. */ addPagination(ucWrapper) { if ($(ucWrapper).hasClass('uc-pag')) { if ($(ucWrapper).find('.products-section-title').length) { $(ucWrapper) .find('.products-section-title') .append( '' ); } else { $(ucWrapper) .find('.swiper-container') .append( '' ); } } } /** * Description. Checking condition of controls. * @listens init */ checkCondition() { if (this.params.direction === 'vertical') { $(this.slides).css('min-height', 0); let verticalHeightArray = $(this.slides).map(function () { return $(this).height(); }).get(); let maxVerticalHeigh = Math.max.apply(null, verticalHeightArray); $(this.$wrapperEl).css('height', maxVerticalHeigh * this.params.slidesPerView); $(this.slides).css('min-height', maxVerticalHeigh); } this.update(); if (this.params.pagination.el.length) { this.params.slidesPerGroup = $(this.$el).find('.swiper-slide-visible').length; this.update(); } if (this.isBeginning && this.isEnd) { this.allowTouchMove = false; this.$el.addClass('hidden-controls'); } else { this.allowTouchMove = true; this.$el.removeClass('hidden-controls'); } } /** * Description. Creating structure for carousel. */ buildStructure(ucWrapper) { this.el.direction = 'horizontal'; //default value this.el.slidesPerView = 'auto'; //default value $(ucWrapper) .find('.' + $(ucWrapper).attr('class').match(/uc-el-(\S+)/i)[1]) .addClass('swiper-slide') .wrapAll('