Current Path : /var/www/www-root/data/www/www.monolith-realty.ru/bitrix/js/ui/carousel/dist/ |
Current File : /var/www/www-root/data/www/www.monolith-realty.ru/bitrix/js/ui/carousel/dist/bundle.min.js |
this.BX=this.BX||{};(function(t,i,s,e){"use strict";let r=t=>t,h,a,l,n,d,o,c,f,v;class u{constructor(t={}){this.offsetCache=0;this.target=t.target||null;this.content=t.content||null;this.responsive=t.responsive||null;this.autoPlaySpeed=t.autoPlaySpeed||1e3;this.autoPlay=t.autoPlay||false;this.dots=t.dots||false;this.dotsClass=t.dotsClass||"--default";this.arrows=t.arrows||false;this.arrowsClass=t.arrowsClass||"--default";this.vertical=t.vertical||false;this.infinite=t.infinite||false;this.carouselContainer=null;this.wrapper=null;this.track=null;this.nodeDots=null;this.nodeArrows=null;this.arrayDotsItem=[];this.arrayItems=[];this.arrayItemsWidth=0;this.arrayItemsHeight=0;this.isLastSlide=0;this.arrayArrowsItem=[];this.slidActive=1;this.sliderInterval=null;this.sliderAllCount=this.content.length;this.defaultSettings()}defaultSettings(){this.defaultParameters={};for(let t in this){this.defaultParameters[t]=this[t]}}getItem(t,s){let e=this.slidActive-1===s?"--active":"";let a=i.Tag.render(h||(h=r` <div class="ui-carousel__slide ${0}"> ${0} </div> `),e,t.html);i.Event.bind(a,"mouseenter",this.stopSlide.bind(this));i.Event.bind(a,"mouseleave",this.runSlide.bind(this));if(this.arrayItems.indexOf(t)===-1){this.arrayItems.push(a)}return a}setTrackCharacteristics(){if(this.arrayItemsWidth===0&&this.arrayItemsHeight===0){for(let t=0;t<this.arrayItems.length;t++){this.arrayItemsWidth+=this.arrayItems[t].offsetWidth;this.arrayItemsHeight+=this.arrayItems[t].offsetHeight}}}initSlider(){this.runSlide()}stopSlide(){clearInterval(this.sliderInterval)}changeActivePoint(){if(this.arrayDotsItem.length>1){for(let t=0;t<this.arrayDotsItem.length;t++){if(this.arrayDotsItem[t].classList.contains("--active")){this.arrayDotsItem[t].classList.remove("--active")}}this.arrayDotsItem[this.slidActive-1].classList.add("--active")}}changeActiveSlide(){if(this.arrayItems.length>1){for(let t=0;t<this.arrayItems.length;t++){if(this.arrayItems[t].classList.contains("--active")){this.arrayItems[t].classList.remove("--active")}}this.arrayItems[this.slidActive-1].classList.add("--active")}}changeActiveArrow(t){if(!this.infinite){this.arrayArrowsItem.map((t=>{t.classList.remove("--disabled")}));if(this.slidActive===this.sliderAllCount||t>=this.isLastSlide&&this.isLastSlide>0){this.arrayArrowsItem[this.arrayArrowsItem.length-1].classList.add("--disabled")}else if(this.slidActive===1){this.arrayArrowsItem[0].classList.add("--disabled")}}}changeActive(t){this.changeActivePoint();this.changeActiveSlide();if(!this.infinite){this.changeActiveArrow(t)}}runSlide(){if(this.sliderAllCount>1&&this.autoPlay){this.trackOffsetStep();this.sliderInterval=setInterval((()=>{let t=this.slidActive+1>this.sliderAllCount?1:this.slidActive+1;this.showSlide(t)}),this.autoPlaySpeed)}}trackOffsetStep(){if(this.offsetCache===0){this.offsetCache=this.wrapper?this.wrapper.offsetWidth:0}return this.offsetCache}getTrackShift(t){let i=0;if(t>1){let s=0;if(t>=this.isLastSlide&&this.isLastSlide>0){s=this.isLastSlide-1}else{s=t-1}if(this.vertical){let e=this.arrayItemsHeight;for(let r=0;r<s;r++){e-=this.arrayItems[r].offsetHeight;if(e<this.wrapper.offsetHeight){this.isLastSlide=t;i+=e+this.arrayItems[r].offsetHeight-this.wrapper.offsetHeight}else{i+=this.arrayItems[r].offsetHeight}}}else{let e=this.arrayItemsWidth;for(let r=0;r<s;r++){e-=this.arrayItems[r].offsetWidth;if(e<this.wrapper.offsetWidth){this.isLastSlide=t;i+=e+this.arrayItems[r].offsetWidth-this.wrapper.offsetWidth}else{i+=this.arrayItems[r].offsetWidth}}}}return i}showSlide(t){this.setTrackCharacteristics();if(t>0&&t<=this.sliderAllCount){this.slidActive=t;if(this.track){if(this.vertical){this.track.style.transform="translateY("+-this.getTrackShift(t)+"px)"}else{this.track.style.transform="translateX("+-this.getTrackShift(t)+"px)"}}}clearInterval(this.sliderInterval);this.runSlide();this.changeActive(t)}nextSlide(){if(this.infinite){if(this.slidActive===this.sliderAllCount){this.slidActive=1;this.showSlide(this.slidActive)}else if(this.slidActive<this.sliderAllCount){this.slidActive+=1;this.showSlide(this.slidActive)}}else{if(this.slidActive<this.sliderAllCount){this.slidActive+=1;this.showSlide(this.slidActive)}}}prevSlide(){if(this.infinite){if(this.slidActive===1){this.slidActive=this.sliderAllCount;this.showSlide(this.slidActive)}else if(this.slidActive>1){this.slidActive-=1;this.showSlide(this.slidActive)}}else{if(this.slidActive>1){this.slidActive-=1;this.showSlide(this.slidActive)}}}getArrows(){let t=this.vertical?"--vertical":"";this.nodeArrows=i.Tag.render(a||(a=r` <div class="ui-carousel__arrows--container ${0}"></div> `),t);let s=this.infinite?"":"--disabled";let e=i.Tag.render(l||(l=r` <div class="ui-carousel__arrow ${0} --prev ${0} ${0}"></div> `),this.arrowsClass,s,t);let h=i.Tag.render(n||(n=r` <div class="ui-carousel__arrow ${0} --next ${0}"></div> `),this.arrowsClass,t);i.Event.bind(e,"click",this.prevSlide.bind(this));i.Event.bind(h,"click",this.nextSlide.bind(this));this.arrayArrowsItem.push(e);this.arrayArrowsItem.push(h);this.nodeArrows.append(e);this.nodeArrows.append(h);return this.nodeArrows}getDots(){this.nodeDots=i.Tag.render(d||(d=r` <div class="ui-carousel__dots ${0}"></div> `),this.dotsClass);for(let t=0;t<this.sliderAllCount;t++){let s=this.slidActive===t+1?"--active":"";let e=i.Tag.render(o||(o=r` <div class="ui-carousel__dots--item ${0} ${0}"> </div> `),this.dotsClass,s);i.Event.bind(e,"click",this.showSlide.bind(this,t+1));this.arrayDotsItem.push(e);this.nodeDots.append(e)}return this.nodeDots}getCarouselContent(){let t=this.vertical?"--vertical":"";this.track=i.Tag.render(c||(c=r` <div class="ui-carousel__track ${0}"></div> `),t);this.content.map(((t,i)=>{this.track.appendChild(this.getItem(t,i))}));this.wrapper=i.Tag.render(f||(f=r` <div class="ui-carousel__wrapper"> ${0} </div> `),this.track);this.carouselContainer=i.Tag.render(v||(v=r` <div class="ui-carousel__container ui-carousel__scope ${0}"> ${0} </div> `),t,this.wrapper);if(this.dots&&this.sliderAllCount>1){this.carouselContainer.appendChild(this.getDots())}if(this.arrows&&this.sliderAllCount>1){this.carouselContainer.appendChild(this.getArrows())}return this.carouselContainer}responsiveCarousel(){if(this.responsive){for(let t=0;t<this.responsive.length;t++){if(window.innerWidth>this.responsive[0].breakpoint){let t=this.defaultParameters;for(let i in t){this[i]=t[i]}break}else if(window.innerWidth<=this.responsive[t].breakpoint){let i=this.responsive[t].settings;for(let t in i){this[t]=i[t]}}}}}carouselResize(){if(this.responsive){window.addEventListener("resize",(()=>{for(let t=0;t<this.responsive.length;t++){if(this.windowWidth>this.responsive[t].breakpoint&&window.innerWidth<this.responsive[t].breakpoint){this.windowWidth=window.innerWidth;this.init()}else if(this.windowWidth<this.responsive[t].breakpoint&&window.innerWidth>this.responsive[t].breakpoint){this.windowWidth=window.innerWidth;this.init()}}}))}}init(){if(this.target&&this.content){this.windowWidth=window.innerWidth;i.Dom.clean(this.target);this.responsiveCarousel();this.target.appendChild(this.getCarouselContent());this.initSlider();this.carouselResize()}}}t.Carousel=u})(this.BX.UI=this.BX.UI||{},BX,BX.Event,BX); //# sourceMappingURL=bundle.map.js