12345678 |
- /*!
- * Splide.js
- * Version : 4.1.3
- * License : MIT
- * Copyright: 2022 Naotoshi Fujita
- */
- var t,s;t=this,s=function(){"use strict";const n={width:["height"],left:["top","right"],right:["bottom","left"],x:["y"],X:["Y"],Y:["X"],ArrowLeft:["ArrowUp","ArrowRight"],ArrowRight:["ArrowDown","ArrowLeft"]};function r(t,s,r){return{resolve:function(t,s,i){const e="rtl"!==(i=i||r.direction)||s?"ttb"===i?0:-1:1;return n[t]&&n[t][e]||t.replace(/width|left|right/i,(t,s)=>{const i=n[t.toLowerCase()][e]||t;return 0<s?i.charAt(0).toUpperCase()+i.slice(1):i})},orient:function(t){return t*("rtl"===r.direction?1:-1)}}}const i="splide";var t=i+"__";const s=i,o=t+"slide",h=o+"--clone";var e=t+"arrow",t=t+"pagination";const l="is-active";const a={type:"slide",role:"region",speed:400,perPage:1,cloneStatus:!0,arrows:!0,pagination:!0,paginationKeyboard:!0,interval:5e3,pauseOnHover:!0,pauseOnFocus:!0,resetProgress:!0,easing:"cubic-bezier(0.25, 1, 0.5, 1)",drag:!0,direction:"ltr",trimSpace:!0,focusableNodes:"a, button, textarea, input, select, iframe",live:!0,classes:{slide:o,clone:h,arrows:"splide__arrows",arrow:e,prev:"splide__arrow--prev",next:"splide__arrow--next",pagination:t,page:"splide__pagination__page",spinner:"splide__spinner"},i18n:{prev:"Previous slide",next:"Next slide",first:"Go to first slide",last:"Go to last slide",slideX:"Go to slide %s",pageX:"Go to page %s",play:"Start autoplay",pause:"Pause autoplay",carousel:"carousel",slide:"slide",select:"Select a slide to show",slideLabel:"%s of %s"},reducedMotion:{speed:0,rewindSpeed:0,autoplay:"pause"}};function u(t,s,i){return Array.prototype.slice.call(t,s,i)}function c(t){return t.bind(null,...u(arguments,1))}function d(t,s){return typeof s===t}function f(t){return null!==t&&d("object",t)}const p=Array.isArray,g=(c(d,"function"),c(d,"string"));function v(t){return p(t)?t:[t]}function b(t,s){v(t).forEach(s)}function w(t,s){return t.push(...v(s)),t}function y(t,s){return function(t){try{return t instanceof(t.ownerDocument.defaultView||window).HTMLElement}catch(t){return!1}}(t)&&(t.msMatchesSelector||t.matches).call(t,s)}function $(t,s){return s?function(t,s){const i=t?u(t.children):[];return s?i.filter(t=>y(t,s)):i}(t,s)[0]:t.firstElementChild}c(d,"undefined");const _=Object.keys;function m(s,i,t){s&&(t?_(s).reverse():_(s)).forEach(t=>{"__proto__"!==t&&i(s[t],t)})}function x(e){return u(arguments,1).forEach(i=>{m(i,(t,s)=>{e[s]=i[s]})}),e}function S(i){return u(arguments,1).forEach(t=>{m(t,(t,s)=>{p(t)?i[s]=t.slice():f(t)?i[s]=S({},f(i[s])?i[s]:{},t):i[s]=t})}),i}function A(t){b(t,t=>{t&&t.parentNode&&t.parentNode.removeChild(t)})}function C(t){return g(t)?t:t?t+"px":""}function T(t,s){if(!t)throw new Error(`[${i}] `+(s||""))}const k=Math["max"];function L(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}const O={};function P(){let h=[];function i(t,i,e){b(t,s=>{s&&b(i,t=>{t.split(" ").forEach(t=>{t=t.split(".");e(s,t[0],t[1])})})})}return{bind:function(t,s,n,o){i(t,s,(t,s,i)=>{var e="addEventListener"in t,r=e?t.removeEventListener.bind(t,s,n,o):t.removeListener.bind(t,n);e?t.addEventListener(s,n,o):t.addListener(n),h.push([t,s,i,n,r])})},unbind:function(t,s,r){i(t,s,(s,i,e)=>{h=h.filter(t=>!!(t[0]!==s||t[1]!==i||t[2]!==e||r&&t[3]!==r)||(t[4](),!1))})},dispatch:function(t,s,i){let e;return"function"==typeof CustomEvent?e=new CustomEvent(s,{bubbles:!0,detail:i}):(e=document.createEvent("CustomEvent")).initCustomEvent(s,!0,!1,i),t.dispatchEvent(e),e},destroy:function(){h.forEach(t=>{t[4]()}),h.length=0}}}function R(t){const i=t?t.event.bus:document.createDocumentFragment(),e=P();return t&&t.event.on("destroy",e.destroy),x(e,{bus:i,on:function(t,s){e.bind(i,v(t).join(" "),t=>{s.apply(s,p(t.detail)?t.detail:[])})},off:c(e.unbind,i),emit:function(t){e.dispatch(i,t,u(arguments,1))}})}const E={listTag:"ul",slideTag:"li"};class G{styles={};id;options;constructor(t,s){this.id=t,this.options=s}rule(t,s,i,e){const r=this.styles[e=e||"default"]=this.styles[e]||{},n=r[t]=r[t]||{};n[s]=i}build(){let s="";return this.styles.default&&(s+=this.buildSelectors(this.styles.default)),Object.keys(this.styles).sort((t,s)=>"min"===this.options.mediaQuery?+t-+s:+s-+t).forEach(t=>{"default"!==t&&(s=(s+=`@media screen and (max-width: ${t}px) {`)+this.buildSelectors(this.styles[t])+"}")}),s}buildSelectors(t){let i="";return m(t,(t,s)=>{s=(`#${this.id} `+s).trim(),i+=s+" {",m(t,(t,s)=>{!t&&0!==t||(i+=s+`: ${t};`)}),i+="}"}),i}}return class{static clean(t){const s=R(t)["on"],i=t["root"];t=i;var e,t=(e="."+h)?u(t.querySelectorAll(e)):[];s("mounted",()=>{A($(i,"style"))}),A(t)}contents;slides=[];Direction;Style;options={};config;id;breakpoints=[];constructor(t,s,i,e){S(a,e||{}),S(S(this.options,a),s||{}),this.contents=t,this.config=x({},E,i||{}),this.id=this.config.id||""+(e="splide")+((e=O[e]=(O[e]||0)+1)<10?"0"+e:""+e),this.Style=new G(this.id,this.options),this.Direction=r(0,0,this.options),T(this.contents.length,"Provide at least 1 content."),this.init()}init(){this.parseBreakpoints(),this.initSlides(),this.registerRootStyles(),this.registerTrackStyles(),this.registerSlideStyles(),this.registerListStyles()}initSlides(){w(this.slides,this.contents.map((t,s)=>{(t=g(t)?{html:t}:t).styles=t.styles||{},t.attrs=t.attrs||{},this.cover(t);s=this.options.classes.slide+" "+(0===s?"is-active":"");return x(t.attrs,{class:(s+" "+(t.attrs.class||"")).trim(),style:this.buildStyles(t.styles)}),t})),this.isLoop()&&this.generateClones(this.slides)}registerRootStyles(){this.breakpoints.forEach(([t,s])=>{this.Style.rule(" ","max-width",C(s.width),t)})}registerTrackStyles(){const i=this["Style"],e=".splide__track";this.breakpoints.forEach(([t,s])=>{i.rule(e,this.resolve("paddingLeft"),this.cssPadding(s,!1),t),i.rule(e,this.resolve("paddingRight"),this.cssPadding(s,!0),t),i.rule(e,"height",this.cssTrackHeight(s),t)})}registerListStyles(){const i=this["Style"],e=".splide__list";this.breakpoints.forEach(([t,s])=>{i.rule(e,"transform",this.buildTranslate(s),t),this.cssSlideHeight(s)||i.rule(e,"aspect-ratio",this.cssAspectRatio(s),t)})}registerSlideStyles(){const i=this["Style"],e="."+o;this.breakpoints.forEach(([t,s])=>{i.rule(e,"width",this.cssSlideWidth(s),t),i.rule(e,"height",this.cssSlideHeight(s)||"100%",t),i.rule(e,this.resolve("marginRight"),C(s.gap)||"0px",t),i.rule(e+" > img","display",s.cover?"none":"inline",t)})}buildTranslate(t){const{resolve:s,orient:i}=this.Direction,e=[];return e.push(this.cssOffsetClones(t)),e.push(this.cssOffsetGaps(t)),this.isCenter(t)&&(e.push(this.buildCssValue(i(-50),"%")),e.push(...this.cssOffsetCenter(t))),e.filter(Boolean).map(t=>`translate${s("X")}(${t})`).join(" ")}cssOffsetClones(t){const{resolve:s,orient:i}=this.Direction;var e,r,n=this.getCloneCount();return this.isFixedWidth(t)?({value:r,unit:e}=this.parseCssValue(t[s("fixedWidth")]),this.buildCssValue(i(r)*n,e)):(r=100*n/t.perPage,i(r)+"%")}cssOffsetCenter(t){const{resolve:s,orient:i}=this.Direction;if(this.isFixedWidth(t))return{value:r,unit:n}=this.parseCssValue(t[s("fixedWidth")]),[this.buildCssValue(i(r/2),n)];const e=[];var{perPage:r,gap:n}=t;return e.push(i(50/r)+"%"),n&&({value:t,unit:n}=this.parseCssValue(n),e.push(this.buildCssValue(i((t/r-t)/2),n))),e}cssOffsetGaps(t){var s=this.getCloneCount();if(s&&t.gap){const r=this.Direction["orient"];var{value:i,unit:e}=this.parseCssValue(t.gap);return this.isFixedWidth(t)?this.buildCssValue(r(i*s),e):(t=t["perPage"],this.buildCssValue(r(s/t*i),e))}return""}resolve(t){return L(this.Direction.resolve(t))}cssPadding(t,s){t=t.padding,s=this.Direction.resolve(s?"right":"left",!0);return t&&C(t[s]||(f(t)?0:t))||"0px"}cssTrackHeight(t){let s="";return this.isVertical()&&(T(s=this.cssHeight(t),'"height" is missing.'),s=`calc(${s} - ${this.cssPadding(t,!1)} - ${this.cssPadding(t,!0)})`),s}cssHeight(t){return C(t.height)}cssSlideWidth(t){return t.autoWidth?"":C(t.fixedWidth)||(this.isVertical()?"":this.cssSlideSize(t))}cssSlideHeight(t){return C(t.fixedHeight)||(this.isVertical()?t.autoHeight?"":this.cssSlideSize(t):this.cssHeight(t))}cssSlideSize(t){var s=C(t.gap);return`calc((100%${s&&" + "+s})/${t.perPage||1}${s&&" - "+s})`}cssAspectRatio(t){t=t.heightRatio;return t?""+1/t:""}buildCssValue(t,s){return""+t+s}parseCssValue(t){return g(t)?{value:parseFloat(t)||0,unit:t.replace(/\d*(\.\d*)?/,"")||"px"}:{value:t,unit:"px"}}parseBreakpoints(){var t=this.options["breakpoints"];this.breakpoints.push(["default",this.options]),t&&m(t,(t,s)=>{this.breakpoints.push([s,S(S({},this.options),t)])})}isFixedWidth(t){return!!t[this.Direction.resolve("fixedWidth")]}isLoop(){return"loop"===this.options.type}isCenter(t){if("center"===t.focus){if(this.isLoop())return!0;if("slide"===this.options.type)return!this.options.trimSpace}return!1}isVertical(){return"ttb"===this.options.direction}buildClasses(){const t=this["options"];return[s,s+"--"+t.type,s+"--"+t.direction,t.drag&&s+"--draggable",t.isNavigation&&s+"--nav",l,!this.config.hidden&&"is-rendered"].filter(Boolean).join(" ")}buildAttrs(t){let i="";return m(t,(t,s)=>{i+=t?` ${L(s)}="${t}"`:""}),i.trim()}buildStyles(t){let i="";return m(t,(t,s)=>{i+=` ${L(s)}:${t};`}),i.trim()}renderSlides(){const s=this.config["slideTag"];return this.slides.map(t=>`<${s} ${this.buildAttrs(t.attrs)}>${t.html||""}</${s}>`).join("")}cover(t){const{styles:s,html:i=""}=t;this.options.cover&&!this.options.lazyLoad&&(t=i.match(/<img.*?src\s*=\s*(['"])(.+?)\1.*?>/))&&t[2]&&(s.background=`center/cover no-repeat url('${t[2]}')`)}generateClones(e){const r=this.options["classes"],n=this.getCloneCount(),t=e.slice();for(;t.length<n;)w(t,t);w(t.slice(-n).reverse(),t.slice(0,n)).forEach((t,s)=>{var i=x({},t.attrs,{class:t.attrs.class+" "+r.clone}),t=x({},t,{attrs:i});s<n?e.unshift(t):e.push(t)})}getCloneCount(){var t;return this.isLoop()?(t=this["options"],t.clones||k(...this.breakpoints.map(([,t])=>t.perPage))*((t.flickMaxPages||1)+1)):0}renderArrows(){var t="";return(t+=`<div class="${this.options.classes.arrows}">`)+this.renderArrow(!0)+this.renderArrow(!1)+"</div>"}renderArrow(t){var{classes:s,i18n:i}=this.options,s={class:s.arrow+" "+(t?s.prev:s.next),type:"button",ariaLabel:t?i.prev:i.next};return`<button ${this.buildAttrs(s)}><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40" width="40" height="40"><path d="${this.options.arrowPath||"m15.5 0.932-4.3 4.38 14.5 14.6-14.5 14.5 4.3 4.4 14.6-14.6 4.4-4.3-4.4-4.4-14.6-14.6z"}" /></svg></button>`}html(){var{rootClass:t,listTag:s,arrows:i,beforeTrack:e,afterTrack:r,slider:n,beforeSlider:o,afterSlider:h}=this.config;let l="";return l=(l+=`<div id="${this.id}" class="${this.buildClasses()} ${t||""}">`)+`<style>${this.Style.build()}</style>`,n&&(l=l+(o||"")+'<div class="splide__slider">'),l+=e||"",i&&(l+=this.renderArrows()),l=(l=(l=l+'<div class="splide__track">'+`<${s} class="splide__list">`)+this.renderSlides()+`</${s}>`)+"</div>"+(r||""),n&&(l=l+"</div>"+(h||"")),l+="</div>"}}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=s():"function"==typeof define&&define.amd?define(s):(t="undefined"!=typeof globalThis?globalThis:t||self).SplideRenderer=s();
- //# sourceMappingURL=splide-renderer.min.js.map
|