Newer
Older
pre-www / src / assets / js / vendor / swiper / modules / manipulation.min.mjs
function appendSlide(e){const l=this,{params:o,slidesEl:i}=l;o.loop&&l.loopDestroy();const t=e=>{if("string"==typeof e){const l=document.createElement("div");l.innerHTML=e,i.append(l.children[0]),l.innerHTML=""}else i.append(e)};if("object"==typeof e&&"length"in e)for(let l=0;l<e.length;l+=1)e[l]&&t(e[l]);else t(e);l.recalcSlides(),o.loop&&l.loopCreate(),o.observer&&!l.isElement||l.update()}function prependSlide(e){const l=this,{params:o,activeIndex:i,slidesEl:t}=l;o.loop&&l.loopDestroy();let n=i+1;const d=e=>{if("string"==typeof e){const l=document.createElement("div");l.innerHTML=e,t.prepend(l.children[0]),l.innerHTML=""}else t.prepend(e)};if("object"==typeof e&&"length"in e){for(let l=0;l<e.length;l+=1)e[l]&&d(e[l]);n=i+e.length}else d(e);l.recalcSlides(),o.loop&&l.loopCreate(),o.observer&&!l.isElement||l.update(),l.slideTo(n,0,!1)}function addSlide(e,l){const o=this,{params:i,activeIndex:t,slidesEl:n}=o;let d=t;i.loop&&(d-=o.loopedSlides,o.loopDestroy(),o.recalcSlides());const s=o.slides.length;if(e<=0)return void o.prependSlide(l);if(e>=s)return void o.appendSlide(l);let p=d>e?d+1:d;const r=[];for(let l=s-1;l>=e;l-=1){const e=o.slides[l];e.remove(),r.unshift(e)}if("object"==typeof l&&"length"in l){for(let e=0;e<l.length;e+=1)l[e]&&n.append(l[e]);p=d>e?d+l.length:d}else n.append(l);for(let e=0;e<r.length;e+=1)n.append(r[e]);o.recalcSlides(),i.loop&&o.loopCreate(),i.observer&&!o.isElement||o.update(),i.loop?o.slideTo(p+o.loopedSlides,0,!1):o.slideTo(p,0,!1)}function removeSlide(e){const l=this,{params:o,activeIndex:i}=l;let t=i;o.loop&&(t-=l.loopedSlides,l.loopDestroy());let n,d=t;if("object"==typeof e&&"length"in e){for(let o=0;o<e.length;o+=1)n=e[o],l.slides[n]&&l.slides[n].remove(),n<d&&(d-=1);d=Math.max(d,0)}else n=e,l.slides[n]&&l.slides[n].remove(),n<d&&(d-=1),d=Math.max(d,0);l.recalcSlides(),o.loop&&l.loopCreate(),o.observer&&!l.isElement||l.update(),o.loop?l.slideTo(d+l.loopedSlides,0,!1):l.slideTo(d,0,!1)}function removeAllSlides(){const e=this,l=[];for(let o=0;o<e.slides.length;o+=1)l.push(o);e.removeSlide(l)}function Manipulation(e){let{swiper:l}=e;Object.assign(l,{appendSlide:appendSlide.bind(l),prependSlide:prependSlide.bind(l),addSlide:addSlide.bind(l),removeSlide:removeSlide.bind(l),removeAllSlides:removeAllSlides.bind(l)})}export{Manipulation as default};
//# sourceMappingURL=manipulation.min.mjs.map