{text}
+| Prop | \nType | \nDefault | \nDescription |
|---|---|---|---|
arrows | \nboolean | \ntrue | \nEnable Next/Prev arrows |
infinite | \nboolean | \ntrue | \nInfinite looping |
initialPageIndex | \nnumber | \n0 | \nPage to start on |
duration | \nnumber | \n500 | \nTransition duration (ms) |
autoplay | \nboolean | \nfalse | \nEnables auto play of pages |
autoplayDuration | \nnumber | \n3000 | \nAuto play change interval (ms) |
autoplayDirection | \nstring | \n'next' | \nAuto play change direction (next or prev) |
dots | \nboolean | \ntrue | \nCurrent page indicator dots |
pauseOnFocus | \nboolean | \nfalse | \nPause autoplay on focus |
timingFunction | \nstring | \n'ease-in-out' | \nCSS animation timing function |
pageChange",En=b(),In=x("p"),In.textContent="Is dispatched on page change",An=b(),Ln=x("div"),Ln.innerHTML='| Payload field | \nType | \nDescription |
|---|---|---|
event.detail | \nnumber | \nCurrent page index |
prev and next",Rn=b(),Nn=x("p"),Nn.textContent="They are used for customizing prev and next buttons.",Wn=b(),Fn=x("p"),Fn.textContent="Slot props:",Un=b(),Bn=x("div"),Bn.innerHTML='| Prop | \nType | \nDescription |
|---|---|---|
showPrevPage | \nfunction | \nCall it to switch to the previos page |
showNextPage | \nfunction | \nCall it to switch to the next page |
dots",Gn=b(),Yn=x("p"),Yn.textContent="This slot is used for customizing dots appearance.",Xn=b(),Jn=x("p"),Jn.textContent="Slot props:",Qn=b(),nt=x("div"),nt.innerHTML='| Prop | \nType | \nDescription |
|---|---|---|
currentPageIndex | \nnumber | \nRepresents current page index (start from 0) |
pagesCount | \nnumber | \nTotal pages amount |
showPage | \nfunction | \nTakes index as page to be shown |
| Prop | \nType | \nDescription |
|---|---|---|
loaded | \nnumber[] | \nContains indexes of pages to be loaded. Can be used for lazy loading |
<Carousel>\n {#each colors as { color, text } (color)}\n <Color {color} {text} />\n {/each}\n</Carousel>',m(n,c,y),rn(l,n,y),m(n,i,y),m(n,p,y),m(n,f,y),rn(d,n,y),m(n,h,y),m(n,g,y),g.innerHTML='<Carousel>\n {#each _.chunk(colors, 3) as colorsChunk, chunkIndex (chunkIndex)}\n <div style="display: flex;">\n {#each colorsChunk as { color, text } (color)}\n <Color {color} {text} />\n {/each}\n </div>\n {/each}\n</Carousel>',m(n,v,y),rn(k,n,y),m(n,_,y),m(n,w,y),m(n,$,y),rn(j,n,y),m(n,C,y),m(n,P,y),P.innerHTML='<Carousel\n autoplay={true}\n autoplayDuration={2000}\n>\n {#each colors as { color, text } (color)}\n <Color {color} {text} />\n {/each}\n</Carousel>',m(n,E,y),rn(I,n,y),m(n,A,y),m(n,L,y),m(n,O,y),rn(M,n,y),m(n,T,y),m(n,S,y),S.innerHTML='<Carousel\n let:loaded\n>\n {#each images as src, imageIndex (src)}\n <div class="img-container">\n {#if loaded.includes(imageIndex)}\n <img {src} alt="nature" />\n {/if}\n </div>\n {/each}\n</Carousel>',m(n,z,y),rn(D,n,y),m(n,R,y),m(n,N,y),m(n,W,y),rn(F,n,y),m(n,U,y),m(n,B,y),B.innerHTML='<Carousel\n let:showPrevPage\n let:showNextPage\n>\n <div slot="prev" on:click={showPrevPage} class="custom-arrow custom-arrow-prev">\n <i />\n </div>\n {#each colors as { color, text } (color)}\n <Color {color} {text} />\n {/each}\n <div slot="next" on:click={showNextPage} class="custom-arrow custom-arrow-next">\n <i />\n </div>\n</Carousel>',m(n,H,y),rn(Z,n,y),m(n,K,y),m(n,V,y),m(n,G,y),rn(Y,n,y),m(n,X,y),m(n,nn,y),nn.innerHTML='<Carousel\n let:currentPageIndex\n let:pagesCount\n let:showPage\n>\n <div slot="dots" class="custom-dots">\n {#each Array(pagesCount) as _, pageIndex (pageIndex)}\n <CustomDot\n symbol={pageIndex + 1}\n active={currentPageIndex === pageIndex}\n on:click={() => showPage(pageIndex)}\n ></CustomDot>\n {/each}\n </div>\n {#each colors as { color, text } (color)}\n <Color {color} {text} />\n {/each}\n</Carousel>',m(n,tn,y),rn(en,n,y),m(n,on,y),m(n,un,y),m(n,cn,y),rn(ln,n,y),m(n,pn,y),m(n,fn,y),m(n,dn,y),m(n,hn,y),hn.innerHTML='yarn add svelte-carousel',m(n,gn,y),m(n,vn,y),vn.innerHTML='npm install svelte-carousel',m(n,kn,y),m(n,_n,y),m(n,mn,y),m(n,yn,y),yn.innerHTML='<script>\n import Carousel from \'svelte-carousel\'\n // ...\n</script>',m(n,xn,y),m(n,wn,y),m(n,bn,y),m(n,$n,y),m(n,jn,y),m(n,qn,y),m(n,Cn,y),m(n,Pn,y),m(n,En,y),m(n,In,y),m(n,An,y),m(n,Ln,y),m(n,On,y),m(n,Mn,y),Mn.innerHTML='<Carousel\n on:pageChange={\n event => console.log(`Current page index: ${event.detail}`)\n }\n>\n <!-- --\x3e\n</Carousel>',m(n,Tn,y),m(n,Sn,y),m(n,zn,y),m(n,Dn,y),m(n,Rn,y),m(n,Nn,y),m(n,Wn,y),m(n,Fn,y),m(n,Un,y),m(n,Bn,y),m(n,Hn,y),m(n,Zn,y),Zn.innerHTML='<Carousel\n let:showPrevPage\n let:showNextPage\n>\n <div slot="prev">\n <!-- --\x3e\n </div>\n <div slot="next">\n <!-- --\x3e\n </div>\n <!-- --\x3e\n</Carousel>',m(n,Kn,y),m(n,Vn,y),m(n,Gn,y),m(n,Yn,y),m(n,Xn,y),m(n,Jn,y),m(n,Qn,y),m(n,nt,y),m(n,tt,y),m(n,et,y),et.innerHTML='<Carousel\n let:currentPageIndex\n let:pagesCount\n let:showPage\n>\n <div slot="dots">\n <!-- --\x3e\n </div>\n <!-- --\x3e\n</Carousel>',m(n,at,y),m(n,rt,y),m(n,st,y),m(n,ot,y),m(n,ut,y),m(n,ct,y),m(n,lt,y),m(n,it,y),m(n,pt,y),m(n,ft,y),ft.innerHTML='<Carousel\n let:loaded\n>\n <div>\n <!-- --\x3e\n </div>\n <!-- --\x3e\n</Carousel>',m(n,ht,y),rn(gt,n,y),vt=!0},p(n,t){const e={};268435456&t&&(e.$$scope={dirty:t,ctx:n}),s.$set(e);const a={};268435456&t&&(a.$$scope={dirty:t,ctx:n}),d.$set(a);const r={};268435456&t&&(r.$$scope={dirty:t,ctx:n}),j.$set(r);const o={};268468224&t&&(o.$$scope={dirty:t,ctx:n}),M.$set(o);const u={};268441600&t&&(u.$$scope={dirty:t,ctx:n}),F.$set(u);const c={};268435462&t&&(c.$$scope={dirty:t,ctx:n}),Y.$set(c)},i(n){vt||(J(s.$$.fragment,n),J(l.$$.fragment,n),J(d.$$.fragment,n),J(k.$$.fragment,n),J(j.$$.fragment,n),J(I.$$.fragment,n),J(M.$$.fragment,n),J(D.$$.fragment,n),J(F.$$.fragment,n),J(Z.$$.fragment,n),J(Y.$$.fragment,n),J(en.$$.fragment,n),J(ln.$$.fragment,n),J(gt.$$.fragment,n),vt=!0)},o(n){Q(s.$$.fragment,n),Q(l.$$.fragment,n),Q(d.$$.fragment,n),Q(k.$$.fragment,n),Q(j.$$.fragment,n),Q(I.$$.fragment,n),Q(M.$$.fragment,n),Q(D.$$.fragment,n),Q(F.$$.fragment,n),Q(Z.$$.fragment,n),Q(Y.$$.fragment,n),Q(en.$$.fragment,n),Q(ln.$$.fragment,n),Q(gt.$$.fragment,n),vt=!1},d(n){n&&y(t),n&&y(e),n&&y(a),n&&y(r),sn(s,n),n&&y(o),n&&y(u),n&&y(c),sn(l,n),n&&y(i),n&&y(p),n&&y(f),sn(d,n),n&&y(h),n&&y(g),n&&y(v),sn(k,n),n&&y(_),n&&y(w),n&&y($),sn(j,n),n&&y(C),n&&y(P),n&&y(E),sn(I,n),n&&y(A),n&&y(L),n&&y(O),sn(M,n),n&&y(T),n&&y(S),n&&y(z),sn(D,n),n&&y(R),n&&y(N),n&&y(W),sn(F,n),n&&y(U),n&&y(B),n&&y(H),sn(Z,n),n&&y(K),n&&y(V),n&&y(G),sn(Y,n),n&&y(X),n&&y(nn),n&&y(tn),sn(en,n),n&&y(on),n&&y(un),n&&y(cn),sn(ln,n),n&&y(pn),n&&y(fn),n&&y(dn),n&&y(hn),n&&y(gn),n&&y(vn),n&&y(kn),n&&y(_n),n&&y(mn),n&&y(yn),n&&y(xn),n&&y(wn),n&&y(bn),n&&y($n),n&&y(jn),n&&y(qn),n&&y(Cn),n&&y(Pn),n&&y(En),n&&y(In),n&&y(An),n&&y(Ln),n&&y(On),n&&y(Mn),n&&y(Tn),n&&y(Sn),n&&y(zn),n&&y(Dn),n&&y(Rn),n&&y(Nn),n&&y(Wn),n&&y(Fn),n&&y(Un),n&&y(Bn),n&&y(Hn),n&&y(Zn),n&&y(Kn),n&&y(Vn),n&&y(Gn),n&&y(Yn),n&&y(Xn),n&&y(Jn),n&&y(Qn),n&&y(nt),n&&y(tt),n&&y(et),n&&y(at),n&&y(rt),n&&y(st),n&&y(ot),n&&y(ut),n&&y(ct),n&&y(lt),n&&y(it),n&&y(pt),n&&y(ft),n&&y(ht),sn(gt,n)}}}function de(n){let t,e;return t=new dn({props:{$$slots:{default:[fe]},$$scope:{ctx:n}}}),{c(){an(t.$$.fragment)},m(n,a){rn(t,n,a),e=!0},p(n,[e]){const a={};268435456&e&&(a.$$scope={dirty:e,ctx:n}),t.$set(a)},i(n){e||(J(t.$$.fragment,n),e=!0)},o(n){Q(t.$$.fragment,n),e=!1},d(n){sn(t,n)}}}function he(n){return[(n,t)=>n(t)]}class ge extends un{constructor(n){super(),on(this,n,he,de,u,{})}}function ve(t){let e,a,r;return a=new ge({}),{c(){e=x("main"),an(a.$$.fragment)},m(n,t){m(n,e,t),rn(a,e,null),r=!0},p:n,i(n){r||(J(a.$$.fragment,n),r=!0)},o(n){Q(a.$$.fragment,n),r=!1},d(n){n&&y(e),sn(a)}}}return new class extends un{constructor(n){super(),on(this,n,null,ve,u,{})}}({target:document.body})}();
+var gn,vn=(function(n,t){(function(){var e,a="Expected a function",s="__lodash_hash_undefined__",r="__lodash_placeholder__",o=16,c=32,u=64,l=128,i=256,p=1/0,f=9007199254740991,d=NaN,h=4294967295,g=[["ary",l],["bind",1],["bindKey",2],["curry",8],["curryRight",o],["flip",512],["partial",c],["partialRight",u],["rearg",i]],v="[object Arguments]",k="[object Array]",m="[object Boolean]",_="[object Date]",x="[object Error]",y="[object Function]",b="[object GeneratorFunction]",w="[object Map]",$="[object Number]",q="[object Object]",j="[object Promise]",C="[object RegExp]",P="[object Set]",E="[object String]",A="[object Symbol]",T="[object WeakMap]",I="[object ArrayBuffer]",L="[object DataView]",M="[object Float32Array]",O="[object Float64Array]",S="[object Int8Array]",D="[object Int16Array]",z="[object Int32Array]",N="[object Uint8Array]",R="[object Uint8ClampedArray]",W="[object Uint16Array]",H="[object Uint32Array]",F=/\b__p \+= '';/g,U=/\b(__p \+=) '' \+/g,B=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Z=/&(?:amp|lt|gt|quot|#39);/g,G=/[&<>"']/g,K=RegExp(Z.source),V=RegExp(G.source),Y=/<%-([\s\S]+?)%>/g,X=/<%([\s\S]+?)%>/g,J=/<%=([\s\S]+?)%>/g,Q=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,nn=/^\w*$/,tn=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,en=/[\\^$.*+?()[\]{}|]/g,an=RegExp(en.source),sn=/^\s+|\s+$/g,rn=/^\s+/,on=/\s+$/,cn=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,un=/\{\n\/\* \[wrapped with (.+)\] \*/,ln=/,? & /,pn=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,fn=/\\(\\)?/g,dn=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,gn=/\w*$/,vn=/^[-+]0x[0-9a-f]+$/i,kn=/^0b[01]+$/i,mn=/^\[object .+?Constructor\]$/,_n=/^0o[0-7]+$/i,xn=/^(?:0|[1-9]\d*)$/,yn=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,bn=/($^)/,wn=/['\n\r\u2028\u2029\\]/g,$n="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",qn="\\u2700-\\u27bf",jn="a-z\\xdf-\\xf6\\xf8-\\xff",Cn="A-Z\\xc0-\\xd6\\xd8-\\xde",Pn="\\ufe0e\\ufe0f",En="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",An="['’]",Tn="[\\ud800-\\udfff]",In="["+En+"]",Ln="["+$n+"]",Mn="\\d+",On="[\\u2700-\\u27bf]",Sn="["+jn+"]",Dn="[^\\ud800-\\udfff"+En+Mn+qn+jn+Cn+"]",zn="\\ud83c[\\udffb-\\udfff]",Nn="[^\\ud800-\\udfff]",Rn="(?:\\ud83c[\\udde6-\\uddff]){2}",Wn="[\\ud800-\\udbff][\\udc00-\\udfff]",Hn="["+Cn+"]",Fn="(?:"+Sn+"|"+Dn+")",Un="(?:"+Hn+"|"+Dn+")",Bn="(?:['’](?:d|ll|m|re|s|t|ve))?",Zn="(?:['’](?:D|LL|M|RE|S|T|VE))?",Gn="(?:"+Ln+"|"+zn+")?",Kn="[\\ufe0e\\ufe0f]?",Vn=Kn+Gn+"(?:\\u200d(?:"+[Nn,Rn,Wn].join("|")+")"+Kn+Gn+")*",Yn="(?:"+[On,Rn,Wn].join("|")+")"+Vn,Xn="(?:"+[Nn+Ln+"?",Ln,Rn,Wn,Tn].join("|")+")",Jn=RegExp(An,"g"),Qn=RegExp(Ln,"g"),nt=RegExp(zn+"(?="+zn+")|"+Xn+Vn,"g"),tt=RegExp([Hn+"?"+Sn+"+"+Bn+"(?="+[In,Hn,"$"].join("|")+")",Un+"+"+Zn+"(?="+[In,Hn+Fn,"$"].join("|")+")",Hn+"?"+Fn+"+"+Bn,Hn+"+"+Zn,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Mn,Yn].join("|"),"g"),et=RegExp("[\\u200d\\ud800-\\udfff"+$n+Pn+"]"),at=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,st=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],rt=-1,ot={};ot[M]=ot[O]=ot[S]=ot[D]=ot[z]=ot[N]=ot[R]=ot[W]=ot[H]=!0,ot[v]=ot[k]=ot[I]=ot[m]=ot[L]=ot[_]=ot[x]=ot[y]=ot[w]=ot[$]=ot[q]=ot[C]=ot[P]=ot[E]=ot[T]=!1;var ct={};ct[v]=ct[k]=ct[I]=ct[L]=ct[m]=ct[_]=ct[M]=ct[O]=ct[S]=ct[D]=ct[z]=ct[w]=ct[$]=ct[q]=ct[C]=ct[P]=ct[E]=ct[A]=ct[N]=ct[R]=ct[W]=ct[H]=!0,ct[x]=ct[y]=ct[T]=!1;var ut={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},lt=parseFloat,it=parseInt,pt="object"==typeof hn&&hn&&hn.Object===Object&&hn,ft="object"==typeof self&&self&&self.Object===Object&&self,dt=pt||ft||Function("return this")(),ht=t&&!t.nodeType&&t,gt=ht&&n&&!n.nodeType&&n,vt=gt&>.exports===ht,kt=vt&&pt.process,mt=function(){try{var n=gt&>.require&>.require("util").types;return n||kt&&kt.binding&&kt.binding("util")}catch(n){}}(),_t=mt&&mt.isArrayBuffer,xt=mt&&mt.isDate,yt=mt&&mt.isMap,bt=mt&&mt.isRegExp,wt=mt&&mt.isSet,$t=mt&&mt.isTypedArray;function qt(n,t,e){switch(e.length){case 0:return n.call(t);case 1:return n.call(t,e[0]);case 2:return n.call(t,e[0],e[1]);case 3:return n.call(t,e[0],e[1],e[2])}return n.apply(t,e)}function jt(n,t,e,a){for(var s=-1,r=null==n?0:n.length;++s{l[m]()}),k))}function M(){clearInterval(E),E=null}let O=[];function D(n){W(n+Number(f),{offsetDelayMs:0,animated:!0})}function z(n){e(6,g=n?h:0),e(8,C=-$*j),f&&(0===$?W(q-2,{offsetDelayMs:h,animated:!1}):$===q-1&&W(1,{offsetDelayMs:h,animated:!1}))}!function(n){I().$$.on_mount.push(n)}((()=>{(async()=>{var n;await H(),O.push(w.subscribe((n=>{e(29,$=n.currentPageIndex)}))),b&&y&&(e(11,r=[0,b.children.length-1]),await H(),f&&function(){const n=b.children[0],t=b.children[b.children.length-1];b.prepend(t.cloneNode(!0)),b.append(n.cloneNode(!0))}(),w.init(d+Number(f)),A()),T(),n=A,window.addEventListener("resize",n)})()})),function(n){I().$$.on_destroy.push(n)}((()=>{var n;M(),n=A,window.removeEventListener("resize",n),O.filter((n=>n&&"function"==typeof n)).forEach((n=>n()))}));let N=!1;function R(n,t){const e=nt(t,"animated",!0);N||(n(),N=!0,setTimeout((()=>{N=!1}),e?h:0))}function W(n,t){const e=nt(t,"animated",!0),a=nt(t,"offsetDelayMs",!0);R((()=>{w.moveToPage({pageIndex:n,pagesCount:q}),setTimeout((()=>{z(e)}),a)}),{animated:e})}function F(n){const t=nt(n,"animated",!0);R((()=>{w.prev({infinite:f,pagesCount:q}),z(t)}),{animated:t})}function U(n){const t=nt(n,"animated",!0);R((()=>{w.next({infinite:f,pagesCount:q}),z(t)}),{animated:t})}return n.$$set=n=>{"timingFunction"in n&&e(0,i=n.timingFunction),"arrows"in n&&e(1,p=n.arrows),"infinite"in n&&e(2,f=n.infinite),"initialPageIndex"in n&&e(20,d=n.initialPageIndex),"duration"in n&&e(21,h=n.duration),"autoplay"in n&&e(22,v=n.autoplay),"autoplayDuration"in n&&e(23,k=n.autoplayDuration),"autoplayDirection"in n&&e(24,m=n.autoplayDirection),"pauseOnFocus"in n&&e(25,_=n.pauseOnFocus),"dots"in n&&e(3,x=n.dots),"$$scope"in n&&e(32,c=n.$$scope)},n.$$.update=()=>{536870916&n.$$.dirty[0]&&e(4,a=$-Number(f)),16&n.$$.dirty[0]&&u("pageChange",a),1073741828&n.$$.dirty[0]&&e(5,s=Math.max(q-(f?2:0),1)),33554432&n.$$.dirty[0]|1&n.$$.dirty[1]&&_&&(P?M():T()),52&n.$$.dirty[0]&&e(11,r=function(n,t,e){if(t<1)throw new Error("pagesCount must be at least 1");var a=Math.max(0,Math.min(n,t-1)),s=a-1,r=a+1;return s=s<0?e?t-1:0:s,r=r>t-1?e?0:t-1:r,xn(new Set([s,r,a])).sort((function(n,t){return n-t}))}(a,s,f))},[i,p,f,x,a,s,g,j,C,y,b,r,D,F,U,function(){e(6,g=0)},function(n){l[n.detail.direction]()},function(n){e(8,C+=n.detail.dx)},function(){W($,{offsetDelayMs:0,animated:!0})},function(n){e(31,P=n.detail.value)},d,h,v,k,m,_,function(n,t){const e=nt(t,"animated",!0);if("number"!=typeof n)throw new Error("pageIndex should be a number");W(n+Number(f),{offsetDelayMs:0,animated:e})},function(n){F({animated:nt(n,"animated",!0)})},function(n){U({animated:nt(n,"animated",!0)})},$,q,P,c,o,()=>j/3,function(n){S[n?"unshift":"push"]((()=>{b=n,e(10,b)}))},function(n){S[n?"unshift":"push"]((()=>{y=n,e(9,y)}))},n=>D(n.detail)]}class ht extends cn{constructor(n){super(),on(this,n,dt,ft,c,{timingFunction:0,arrows:1,infinite:2,initialPageIndex:20,duration:21,autoplay:22,autoplayDuration:23,autoplayDirection:24,pauseOnFocus:25,dots:3,goTo:26,goToPrev:27,goToNext:28},[-1,-1])}get goTo(){return this.$$.ctx[26]}get goToPrev(){return this.$$.ctx[27]}get goToNext(){return this.$$.ctx[28]}}function gt(t){let e,a,s;return{c(){e=y("div"),a=y("p"),s=b(t[1]),j(a,"class","svelte-1bsdhrs"),j(e,"class","color-container svelte-1bsdhrs"),P(e,"background-color",t[0])},m(n,t){_(n,e,t),m(e,a),m(a,s)},p(n,[t]){2&t&&C(s,n[1]),1&t&&P(e,"background-color",n[0])},i:n,o:n,d(n){n&&x(e)}}}function vt(n,t,e){let{color:a}=t,{text:s}=t;return n.$$set=n=>{"color"in n&&e(0,a=n.color),"text"in n&&e(1,s=n.text)},[a,s]}class kt extends cn{constructor(n){super(),on(this,n,vt,gt,c,{color:0,text:1})}}function mt(n){let t,e;return{c(){t=y("img"),t.src!==(e=n[0])&&j(t,"src",e),j(t,"alt",n[1]),j(t,"class","svelte-1cv82er")},m(n,e){_(n,t,e)},p(n,a){1&a&&t.src!==(e=n[0])&&j(t,"src",e),2&a&&j(t,"alt",n[1])},d(n){n&&x(t)}}}function _t(t){let e,a=t[2]&&mt(t);return{c(){e=y("div"),a&&a.c(),j(e,"class","image-container svelte-1cv82er")},m(n,t){_(n,e,t),a&&a.m(e,null)},p(n,[t]){n[2]?a?a.p(n,t):(a=mt(n),a.c(),a.m(e,null)):a&&(a.d(1),a=null)},i:n,o:n,d(n){n&&x(e),a&&a.d()}}}function xt(n,t,e){let{src:a}=t,{alt:s}=t,{loaded:r=!1}=t;return n.$$set=n=>{"src"in n&&e(0,a=n.src),"alt"in n&&e(1,s=n.alt),"loaded"in n&&e(2,r=n.loaded)},[a,s,r]}class yt extends cn{constructor(n){super(),on(this,n,xt,_t,c,{src:0,alt:1,loaded:2})}}var bt={forest:{title:"Forest",tags:["forest","trees"],images:["https://cdn.pixabay.com/photo/2017/04/09/09/56/avenue-2215317_1280.jpg","https://cdn.pixabay.com/photo/2017/11/12/13/37/forest-2942477_1280.jpg","https://cdn.pixabay.com/photo/2016/08/11/23/55/trees-1587301_1280.jpg","https://cdn.pixabay.com/photo/2016/08/16/19/09/forest-1598756_1280.jpg","https://cdn.pixabay.com/photo/2016/11/29/07/12/forest-1868028_1280.jpg","https://cdn.pixabay.com/photo/2015/03/26/09/45/woods-690257_1280.jpg"]},birds:{title:"Birds",tags:["birds","owl","parrot"],images:["https://cdn.pixabay.com/photo/2016/11/18/12/14/owl-1834152_1280.jpg","https://cdn.pixabay.com/photo/2016/05/26/04/19/macaw-1416388_1280.jpg"]},flowers:{title:"Flowers",tags:["flowers","blossom","beauty"],images:["https://cdn.pixabay.com/photo/2018/09/06/23/37/hydrangea-3659614_1280.jpg","https://cdn.pixabay.com/photo/2016/04/12/18/19/carnation-1325012_1280.jpg","https://cdn.pixabay.com/photo/2017/06/06/19/18/rose-2378156_1280.jpg"]},coffee:{title:"Coffee",tags:["coffee","cup"],images:["https://cdn.pixabay.com/photo/2017/05/12/08/29/coffee-2306471_1280.jpg","https://cdn.pixabay.com/photo/2016/03/30/21/59/coffee-beans-1291656_1280.jpg","https://cdn.pixabay.com/photo/2018/01/31/09/57/coffee-3120750_1280.jpg"]}};function wt(n,t,e){const a=n.slice();return a[0]=t[e][0],a[1]=t[e][1],a}function $t(n,t,e){const a=n.slice();return a[4]=t[e],a}function qt(n,t,e){const a=n.slice();return a[10]=t[e],a[12]=e,a}function jt(n){let t,e,a;return{c(){t=y("div"),t.innerHTML='',j(t,"slot","prev"),j(t,"class","album-arrow album-arrow-prev svelte-tqqkfc")},m(s,r){_(s,t,r),e||(a=q(t,"click",(function(){o(n[7])&&n[7].apply(this,arguments)})),e=!0)},p(t,e){n=t},d(n){n&&x(t),e=!1,a()}}}function Ct(n,t){let e,a,s;return a=new yt({props:{src:t[10],alt:t[1].title,loaded:t[9].includes(t[12])}}),{key:n,first:null,c(){e=$(),an(a.$$.fragment),this.first=e},m(n,t){_(n,e,t),sn(a,n,t),s=!0},p(n,e){t=n;const s={};512&e&&(s.loaded=t[9].includes(t[12])),a.$set(s)},i(n){s||(J(a.$$.fragment,n),s=!0)},o(n){Q(a.$$.fragment,n),s=!1},d(n){n&&x(e),rn(a,n)}}}function Pt(n){let t,e,a;return{c(){t=y("div"),t.innerHTML='',j(t,"slot","next"),j(t,"class","album-arrow album-arrow-next svelte-tqqkfc")},m(s,r){_(s,t,r),e||(a=q(t,"click",(function(){o(n[8])&&n[8].apply(this,arguments)})),e=!0)},p(t,e){n=t},d(n){n&&x(t),e=!1,a()}}}function Et(n){let t,e,a,s=[],r=new Map,o=n[1].images;const c=n=>n[10];for(let t=0;t1?"s":""}`;var f;let d,h,g,v,k,$=[],q=new Map;a=new ht({props:{$$slots:{default:[Et,({showPrevPage:n,showNextPage:t,loaded:e})=>({7:n,8:t,9:e}),({showPrevPage:n,showNextPage:t,loaded:e})=>(n?128:0)|(t?256:0)|(e?512:0)],next:[Pt,({showPrevPage:n,showNextPage:t,loaded:e})=>({7:n,8:t,9:e}),({showPrevPage:n,showNextPage:t,loaded:e})=>(n?128:0)|(t?256:0)|(e?512:0)],prev:[jt,({showPrevPage:n,showNextPage:t,loaded:e})=>({7:n,8:t,9:e}),({showPrevPage:n,showNextPage:t,loaded:e})=>(n?128:0)|(t?256:0)|(e?512:0)]},$$scope:{ctx:t}}});let C=t[1].tags;const P=n=>n[4];for(let n=0;n n[0];for(let t=0;t {"active"in n&&e(0,a=n.active),"symbol"in n&&e(1,s=n.symbol)},[a,s,function(t){M(n,t)}]}class zt extends cn{constructor(n){super(),on(this,n,Dt,St,c,{active:0,symbol:1})}}var Nt=["https://cdn.pixabay.com/photo/2017/03/13/10/25/hummingbird-2139278_1280.jpg","https://cdn.pixabay.com/photo/2015/09/02/13/24/mountains-919040_1280.jpg","https://cdn.pixabay.com/photo/2018/07/09/18/17/apple-3526737_1280.jpg","https://cdn.pixabay.com/photo/2016/08/30/16/05/leaf-1631181_1280.jpg","https://cdn.pixabay.com/photo/2019/11/13/11/01/meadow-4623279_1280.jpg"],Rt=[{color:"#85d78b",text:"#85d78b"},{color:"#71d077",text:"#71d077"},{color:"#5dca64",text:"#5dca64"},{color:"#49c351",text:"#49c351"},{color:"#35bd3e",text:"#35bd3e"},{color:"#2faa37",text:"#2faa37"},{color:"#2a9731",text:"#2a9731"},{color:"#25842b",text:"#25842b"},{color:"#1f7125",text:"#1f7125"}];function Wt(n,t,e){const a=n.slice();return a[4]=t[e].color,a[5]=t[e].text,a}function Ht(n,t,e){const a=n.slice();return a[8]=t[e],a[10]=e,a}function Ft(n,t,e){const a=n.slice();return a[4]=t[e].color,a[5]=t[e].text,a}function Ut(n,t,e){const a=n.slice();return a[16]=t[e],a[18]=e,a}function Bt(n,t,e){const a=n.slice();return a[4]=t[e].color,a[5]=t[e].text,a}function Zt(n,t,e){const a=n.slice();return a[21]=t[e],a[23]=e,a}function Gt(n,t,e){const a=n.slice();return a[4]=t[e].color,a[5]=t[e].text,a}function Kt(n,t,e){const a=n.slice();return a[4]=t[e].color,a[5]=t[e].text,a}function Vt(n,t){let e,a,s;return a=new kt({props:{color:t[4],text:t[5]}}),{key:n,first:null,c(){e=$(),an(a.$$.fragment),this.first=e},m(n,t){_(n,e,t),sn(a,n,t),s=!0},p(n,e){t=n},i(n){s||(J(a.$$.fragment,n),s=!0)},o(n){Q(a.$$.fragment,n),s=!1},d(n){n&&x(e),rn(a,n)}}}function Yt(n){let t,e,a=[],s=new Map,r=Rt;const o=n=>n[4];for(let t=0;t n[4];for(let n=0;n n[23];for(let t=0;t n[4];for(let t=0;t n[16];for(let t=0;t ',j(t,"slot","prev"),j(t,"class","custom-arrow custom-arrow-prev svelte-14lrqxf")},m(s,r){_(s,t,r),e||(a=q(t,"click",(function(){o(n[11])&&n[11].apply(this,arguments)})),e=!0)},p(t,e){n=t},d(n){n&&x(t),e=!1,a()}}}function oe(n,t){let e,a,s;return a=new kt({props:{color:t[4],text:t[5]}}),{key:n,first:null,c(){e=$(),an(a.$$.fragment),this.first=e},m(n,t){_(n,e,t),sn(a,n,t),s=!0},p(n,e){t=n},i(n){s||(J(a.$$.fragment,n),s=!0)},o(n){Q(a.$$.fragment,n),s=!1},d(n){n&&x(e),rn(a,n)}}}function ce(n){let t,e,a;return{c(){t=y("div"),t.innerHTML='',j(t,"slot","next"),j(t,"class","custom-arrow custom-arrow-next svelte-14lrqxf")},m(s,r){_(s,t,r),e||(a=q(t,"click",(function(){o(n[12])&&n[12].apply(this,arguments)})),e=!0)},p(t,e){n=t},d(n){n&&x(t),e=!1,a()}}}function ue(n){let t,e,a,s=[],r=new Map,o=Rt;const c=n=>n[4];for(let t=0;t n[10];for(let t=0;t n[4];for(let t=0;t ({15:n}),({loaded:n})=>n?32768:0]},$$scope:{ctx:n}}}),z=new Ot({}),H=new ht({props:{$$slots:{default:[ue,({showPrevPage:n,showNextPage:t})=>({11:n,12:t}),({showPrevPage:n,showNextPage:t})=>(n?2048:0)|(t?4096:0)],next:[ce,({showPrevPage:n,showNextPage:t})=>({11:n,12:t}),({showPrevPage:n,showNextPage:t})=>(n?2048:0)|(t?4096:0)],prev:[re,({showPrevPage:n,showNextPage:t})=>({11:n,12:t}),({showPrevPage:n,showNextPage:t})=>(n?2048:0)|(t?4096:0)]},$$scope:{ctx:n}}}),Z=new Ot({}),Y=new ht({props:{$$slots:{default:[fe,({currentPageIndex:n,pagesCount:t,showPage:e})=>({1:n,2:t,3:e}),({currentPageIndex:n,pagesCount:t,showPage:e})=>(n?2:0)|(t?4:0)|(e?8:0)],dots:[ie,({currentPageIndex:n,pagesCount:t,showPage:e})=>({1:n,2:t,3:e}),({currentPageIndex:n,pagesCount:t,showPage:e})=>(n?2:0)|(t?4:0)|(e?8:0)]},$$scope:{ctx:n}}}),en=new Ot({}),ln=new Lt({}),fn=new Ot({}),$n=new Ot({}),An=new Ot({}),Hn=new Ot({}),wt=new Ot({}),he=new Ot({}),{c(){t=y("h1"),t.textContent="Features",e=w(),a=y("h2"),a.textContent="Single item",s=w(),an(r.$$.fragment),o=w(),c=y("pre"),u=w(),an(l.$$.fragment),i=w(),p=y("h2"),p.textContent="Multiple items",f=w(),an(d.$$.fragment),h=w(),g=y("pre"),v=w(),an(k.$$.fragment),m=w(),b=y("h2"),b.textContent="Autoplay",$=w(),an(q.$$.fragment),C=w(),P=y("pre"),E=w(),an(A.$$.fragment),T=w(),I=y("h2"),I.textContent="Lazy loading of images",L=w(),an(M.$$.fragment),O=w(),S=y("pre"),D=w(),an(z.$$.fragment),N=w(),R=y("h2"),R.textContent="Arrows customization",W=w(),an(H.$$.fragment),F=w(),U=y("pre"),B=w(),an(Z.$$.fragment),G=w(),K=y("h2"),K.textContent="Dots customization",V=w(),an(Y.$$.fragment),X=w(),nn=y("pre"),tn=w(),an(en.$$.fragment),on=w(),cn=y("h2"),cn.textContent="Use case",un=w(),an(ln.$$.fragment),pn=w(),an(fn.$$.fragment),dn=w(),hn=y("h1"),hn.textContent="Installation",gn=w(),vn=y("pre"),kn=w(),mn=y("pre"),_n=w(),xn=y("p"),xn.textContent="Import component",yn=w(),bn=y("pre"),wn=w(),an($n.$$.fragment),qn=w(),jn=y("h1"),jn.textContent="Props",Cn=w(),Pn=y("div"),Pn.innerHTML=' ',En=w(),an(An.$$.fragment),Tn=w(),In=y("h1"),In.textContent="Events",Ln=w(),Mn=y("h2"),Mn.innerHTML="
\n Prop \nType \nDefault \nDescription \n \n arrows\n boolean\n trueEnable Next/Prev arrows \n \n infinite\n boolean\n trueInfinite looping \n \n initialPageIndex\n number\n 0Page to start on \n \n duration\n number\n 500Transition duration (ms) \n \n autoplay\n boolean\n falseEnables auto play of pages \n \n autoplayDuration\n number\n 3000Auto play change interval (ms) \n \n autoplayDirection\n string\n 'next'Auto play change direction ( nextorprev)\n \n dots\n boolean\n trueCurrent page indicator dots \n \n pauseOnFocus\n boolean\n falsePause autoplay on focus \n timingFunction\n string\n 'ease-in-out'CSS animation timing function pageChange",On=w(),Sn=y("p"),Sn.textContent="Is dispatched on page change",Dn=w(),zn=y("div"),zn.innerHTML='',Nn=w(),Rn=y("pre"),Wn=w(),an(Hn.$$.fragment),Fn=w(),Un=y("h1"),Un.textContent="Slots",Bn=w(),Zn=y("h2"),Zn.innerHTML="
\n Payload field \nType \nDescription \n event.detail\n numberCurrent page index prevandnext",Gn=w(),Kn=y("p"),Kn.textContent="They are used for customizing prev and next buttons.",Vn=w(),Yn=y("p"),Yn.textContent="Slot props:",Xn=w(),Jn=y("div"),Jn.innerHTML='',Qn=w(),nt=y("pre"),tt=w(),et=y("h2"),et.innerHTML="
\n Prop \nType \nDescription \n \n showPrevPage\n functionCall it to switch to the previos page \n showNextPage\n functionCall it to switch to the next page dots",at=w(),st=y("p"),st.textContent="This slot is used for customizing dots appearance.",rt=w(),ot=y("p"),ot.textContent="Slot props:",ct=w(),ut=y("div"),ut.innerHTML='',lt=w(),it=y("pre"),pt=w(),ft=y("h2"),ft.textContent="Default slot",dt=w(),gt=y("p"),gt.textContent="This slot takes content for the carousel.",vt=w(),kt=y("p"),kt.textContent="Slot props:",mt=w(),_t=y("div"),_t.innerHTML='
\n Prop \nType \nDescription \n \n currentPageIndex\n numberRepresents current page index (start from 0) \n \n pagesCount\n numberTotal pages amount \n showPage\n functionTakes index as page to be shown ',xt=w(),yt=y("pre"),bt=w(),an(wt.$$.fragment),$t=w(),qt=y("h1"),qt.textContent="Methods",jt=w(),Ct=y("h2"),Ct.innerHTML="
\n Prop \nType \nDescription \n loaded\n number[]Contains indexes of pages to be loaded. Can be used for lazy loading goTo",Pt=w(),Et=y("p"),Et.textContent="Navigates to a page by index",At=w(),Tt=y("p"),Tt.textContent="Arguments:",It=w(),Mt=y("div"),Mt.innerHTML='',St=w(),Dt=y("pre"),zt=w(),Nt=y("h2"),Nt.innerHTML="
\n Argument \nType \nDefault \nDescription \n \n pageIndex\n number\n Page number \n options.animated\n boolean\n trueShould it be animated or not goToPrev",Rt=w(),Wt=y("p"),Wt.textContent="Navigates to the previous page",Ht=w(),Ft=y("p"),Ft.textContent="Arguments:",Ut=w(),Bt=y("div"),Bt.innerHTML='',Zt=w(),Gt=y("pre"),Kt=w(),Vt=y("h2"),Vt.innerHTML="
\n Argument \nType \nDefault \nDescription \n options.animated\n boolean\n trueShould it be animated or not goToNext",Xt=w(),Jt=y("p"),Jt.textContent="Navigates to the next page",ne=w(),ee=y("p"),ee.textContent="Arguments:",ae=w(),oe=y("div"),oe.innerHTML='',le=w(),pe=y("pre"),de=w(),an(he.$$.fragment),j(c,"class","language-jsx"),j(g,"class","language-jsx"),j(P,"class","language-jsx"),j(S,"class","language-jsx"),j(U,"class","language-jsx"),j(nn,"class","language-jsx"),j(vn,"class","language-bash"),j(mn,"class","language-bash"),j(bn,"class","language-jsx"),j(Pn,"class","table-wrapper svelte-14lrqxf"),j(zn,"class","table-wrapper svelte-14lrqxf"),j(Rn,"class","language-jsx"),j(Jn,"class","table-wrapper svelte-14lrqxf"),j(nt,"class","language-jsx"),j(ut,"class","table-wrapper svelte-14lrqxf"),j(it,"class","language-jsx"),j(_t,"class","table-wrapper svelte-14lrqxf"),j(yt,"class","language-jsx"),j(Mt,"class","table-wrapper svelte-14lrqxf"),j(Dt,"class","language-jsx"),j(Bt,"class","table-wrapper svelte-14lrqxf"),j(Gt,"class","language-jsx"),j(oe,"class","table-wrapper svelte-14lrqxf"),j(pe,"class","language-jsx")},m(n,x){_(n,t,x),_(n,e,x),_(n,a,x),_(n,s,x),sn(r,n,x),_(n,o,x),_(n,c,x),c.innerHTML='
\n Argument \nType \nDefault \nDescription \n options.animated\n boolean\n trueShould it be animated or not <Carousel>\n {#each colors as { color, text } (color)}\n <Color {color} {text} />\n {/each}\n</Carousel>',_(n,u,x),sn(l,n,x),_(n,i,x),_(n,p,x),_(n,f,x),sn(d,n,x),_(n,h,x),_(n,g,x),g.innerHTML='<Carousel>\n {#each _.chunk(colors, 3) as colorsChunk, chunkIndex (chunkIndex)}\n <div style="display: flex;">\n {#each colorsChunk as { color, text } (color)}\n <Color {color} {text} />\n {/each}\n </div>\n {/each}\n</Carousel>',_(n,v,x),sn(k,n,x),_(n,m,x),_(n,b,x),_(n,$,x),sn(q,n,x),_(n,C,x),_(n,P,x),P.innerHTML='<Carousel\n autoplay={true}\n autoplayDuration={2000}\n>\n {#each colors as { color, text } (color)}\n <Color {color} {text} />\n {/each}\n</Carousel>',_(n,E,x),sn(A,n,x),_(n,T,x),_(n,I,x),_(n,L,x),sn(M,n,x),_(n,O,x),_(n,S,x),S.innerHTML='<Carousel\n let:loaded\n>\n {#each images as src, imageIndex (src)}\n <div class="img-container">\n {#if loaded.includes(imageIndex)}\n <img {src} alt="nature" />\n {/if}\n </div>\n {/each}\n</Carousel>',_(n,D,x),sn(z,n,x),_(n,N,x),_(n,R,x),_(n,W,x),sn(H,n,x),_(n,F,x),_(n,U,x),U.innerHTML='<Carousel\n let:showPrevPage\n let:showNextPage\n>\n <div slot="prev" on:click={showPrevPage} class="custom-arrow custom-arrow-prev">\n <i />\n </div>\n {#each colors as { color, text } (color)}\n <Color {color} {text} />\n {/each}\n <div slot="next" on:click={showNextPage} class="custom-arrow custom-arrow-next">\n <i />\n </div>\n</Carousel>',_(n,B,x),sn(Z,n,x),_(n,G,x),_(n,K,x),_(n,V,x),sn(Y,n,x),_(n,X,x),_(n,nn,x),nn.innerHTML='<Carousel\n let:currentPageIndex\n let:pagesCount\n let:showPage\n>\n <div slot="dots" class="custom-dots">\n {#each Array(pagesCount) as _, pageIndex (pageIndex)}\n <CustomDot\n symbol={pageIndex + 1}\n active={currentPageIndex === pageIndex}\n on:click={() => showPage(pageIndex)}\n ></CustomDot>\n {/each}\n </div>\n {#each colors as { color, text } (color)}\n <Color {color} {text} />\n {/each}\n</Carousel>',_(n,tn,x),sn(en,n,x),_(n,on,x),_(n,cn,x),_(n,un,x),sn(ln,n,x),_(n,pn,x),sn(fn,n,x),_(n,dn,x),_(n,hn,x),_(n,gn,x),_(n,vn,x),vn.innerHTML='yarn add svelte-carousel',_(n,kn,x),_(n,mn,x),mn.innerHTML='npm install svelte-carousel',_(n,_n,x),_(n,xn,x),_(n,yn,x),_(n,bn,x),bn.innerHTML='<script>\n import Carousel from \'svelte-carousel\'\n // ...\n</script>',_(n,wn,x),sn($n,n,x),_(n,qn,x),_(n,jn,x),_(n,Cn,x),_(n,Pn,x),_(n,En,x),sn(An,n,x),_(n,Tn,x),_(n,In,x),_(n,Ln,x),_(n,Mn,x),_(n,On,x),_(n,Sn,x),_(n,Dn,x),_(n,zn,x),_(n,Nn,x),_(n,Rn,x),Rn.innerHTML='<Carousel\n on:pageChange={\n event => console.log(`Current page index: ${event.detail}`)\n }\n>\n <!-- --\x3e\n</Carousel>',_(n,Wn,x),sn(Hn,n,x),_(n,Fn,x),_(n,Un,x),_(n,Bn,x),_(n,Zn,x),_(n,Gn,x),_(n,Kn,x),_(n,Vn,x),_(n,Yn,x),_(n,Xn,x),_(n,Jn,x),_(n,Qn,x),_(n,nt,x),nt.innerHTML='<Carousel\n let:showPrevPage\n let:showNextPage\n>\n <div slot="prev">\n <!-- --\x3e\n </div>\n <div slot="next">\n <!-- --\x3e\n </div>\n <!-- --\x3e\n</Carousel>',_(n,tt,x),_(n,et,x),_(n,at,x),_(n,st,x),_(n,rt,x),_(n,ot,x),_(n,ct,x),_(n,ut,x),_(n,lt,x),_(n,it,x),it.innerHTML='<Carousel\n let:currentPageIndex\n let:pagesCount\n let:showPage\n>\n <div slot="dots">\n <!-- --\x3e\n </div>\n <!-- --\x3e\n</Carousel>',_(n,pt,x),_(n,ft,x),_(n,dt,x),_(n,gt,x),_(n,vt,x),_(n,kt,x),_(n,mt,x),_(n,_t,x),_(n,xt,x),_(n,yt,x),yt.innerHTML='<Carousel\n let:loaded\n>\n <div>\n <!-- --\x3e\n </div>\n <!-- --\x3e\n</Carousel>',_(n,bt,x),sn(wt,n,x),_(n,$t,x),_(n,qt,x),_(n,jt,x),_(n,Ct,x),_(n,Pt,x),_(n,Et,x),_(n,At,x),_(n,Tt,x),_(n,It,x),_(n,Mt,x),_(n,St,x),_(n,Dt,x),Dt.innerHTML='<script>\n // ...\n let carousel;\n function goToStartPage() {\n carousel.goTo(0, { animated: false })\n }\n</script>\n\n<Carousel\n bind:this={carousel}\n>\n <!-- --\x3e\n</Carousel>\n<button class="button" on:click={goToStartPage}>Go</button>',_(n,zt,x),_(n,Nt,x),_(n,Rt,x),_(n,Wt,x),_(n,Ht,x),_(n,Ft,x),_(n,Ut,x),_(n,Bt,x),_(n,Zt,x),_(n,Gt,x),Gt.innerHTML='<script>\n // ...\n let carousel;\n function goToPrevPage() {\n carousel.goToPrev({ animated: false })\n }\n</script>\n\n<Carousel\n bind:this={carousel}\n>\n <!-- --\x3e\n</Carousel>\n<button class="button" on:click={goToPrevPage}>Go</button>',_(n,Kt,x),_(n,Vt,x),_(n,Xt,x),_(n,Jt,x),_(n,ne,x),_(n,ee,x),_(n,ae,x),_(n,oe,x),_(n,le,x),_(n,pe,x),pe.innerHTML='<script>\n // ...\n let carousel;\n function goToNextPage() {\n carousel.goToNext({ animated: false })\n }\n</script>\n\n<Carousel\n bind:this={carousel}\n>\n <!-- --\x3e\n</Carousel>\n<button class="button" on:click={goToNextPage}>Go</button>',_(n,de,x),sn(he,n,x),ge=!0},p(n,t){const e={};268435456&t&&(e.$$scope={dirty:t,ctx:n}),r.$set(e);const a={};268435456&t&&(a.$$scope={dirty:t,ctx:n}),d.$set(a);const s={};268435456&t&&(s.$$scope={dirty:t,ctx:n}),q.$set(s);const o={};268468224&t&&(o.$$scope={dirty:t,ctx:n}),M.$set(o);const c={};268441600&t&&(c.$$scope={dirty:t,ctx:n}),H.$set(c);const u={};268435462&t&&(u.$$scope={dirty:t,ctx:n}),Y.$set(u)},i(n){ge||(J(r.$$.fragment,n),J(l.$$.fragment,n),J(d.$$.fragment,n),J(k.$$.fragment,n),J(q.$$.fragment,n),J(A.$$.fragment,n),J(M.$$.fragment,n),J(z.$$.fragment,n),J(H.$$.fragment,n),J(Z.$$.fragment,n),J(Y.$$.fragment,n),J(en.$$.fragment,n),J(ln.$$.fragment,n),J(fn.$$.fragment,n),J($n.$$.fragment,n),J(An.$$.fragment,n),J(Hn.$$.fragment,n),J(wt.$$.fragment,n),J(he.$$.fragment,n),ge=!0)},o(n){Q(r.$$.fragment,n),Q(l.$$.fragment,n),Q(d.$$.fragment,n),Q(k.$$.fragment,n),Q(q.$$.fragment,n),Q(A.$$.fragment,n),Q(M.$$.fragment,n),Q(z.$$.fragment,n),Q(H.$$.fragment,n),Q(Z.$$.fragment,n),Q(Y.$$.fragment,n),Q(en.$$.fragment,n),Q(ln.$$.fragment,n),Q(fn.$$.fragment,n),Q($n.$$.fragment,n),Q(An.$$.fragment,n),Q(Hn.$$.fragment,n),Q(wt.$$.fragment,n),Q(he.$$.fragment,n),ge=!1},d(n){n&&x(t),n&&x(e),n&&x(a),n&&x(s),rn(r,n),n&&x(o),n&&x(c),n&&x(u),rn(l,n),n&&x(i),n&&x(p),n&&x(f),rn(d,n),n&&x(h),n&&x(g),n&&x(v),rn(k,n),n&&x(m),n&&x(b),n&&x($),rn(q,n),n&&x(C),n&&x(P),n&&x(E),rn(A,n),n&&x(T),n&&x(I),n&&x(L),rn(M,n),n&&x(O),n&&x(S),n&&x(D),rn(z,n),n&&x(N),n&&x(R),n&&x(W),rn(H,n),n&&x(F),n&&x(U),n&&x(B),rn(Z,n),n&&x(G),n&&x(K),n&&x(V),rn(Y,n),n&&x(X),n&&x(nn),n&&x(tn),rn(en,n),n&&x(on),n&&x(cn),n&&x(un),rn(ln,n),n&&x(pn),rn(fn,n),n&&x(dn),n&&x(hn),n&&x(gn),n&&x(vn),n&&x(kn),n&&x(mn),n&&x(_n),n&&x(xn),n&&x(yn),n&&x(bn),n&&x(wn),rn($n,n),n&&x(qn),n&&x(jn),n&&x(Cn),n&&x(Pn),n&&x(En),rn(An,n),n&&x(Tn),n&&x(In),n&&x(Ln),n&&x(Mn),n&&x(On),n&&x(Sn),n&&x(Dn),n&&x(zn),n&&x(Nn),n&&x(Rn),n&&x(Wn),rn(Hn,n),n&&x(Fn),n&&x(Un),n&&x(Bn),n&&x(Zn),n&&x(Gn),n&&x(Kn),n&&x(Vn),n&&x(Yn),n&&x(Xn),n&&x(Jn),n&&x(Qn),n&&x(nt),n&&x(tt),n&&x(et),n&&x(at),n&&x(st),n&&x(rt),n&&x(ot),n&&x(ct),n&&x(ut),n&&x(lt),n&&x(it),n&&x(pt),n&&x(ft),n&&x(dt),n&&x(gt),n&&x(vt),n&&x(kt),n&&x(mt),n&&x(_t),n&&x(xt),n&&x(yt),n&&x(bt),rn(wt,n),n&&x($t),n&&x(qt),n&&x(jt),n&&x(Ct),n&&x(Pt),n&&x(Et),n&&x(At),n&&x(Tt),n&&x(It),n&&x(Mt),n&&x(St),n&&x(Dt),n&&x(zt),n&&x(Nt),n&&x(Rt),n&&x(Wt),n&&x(Ht),n&&x(Ft),n&&x(Ut),n&&x(Bt),n&&x(Zt),n&&x(Gt),n&&x(Kt),n&&x(Vt),n&&x(Xt),n&&x(Jt),n&&x(ne),n&&x(ee),n&&x(ae),n&&x(oe),n&&x(le),n&&x(pe),n&&x(de),rn(he,n)}}}function he(n){let t,e;return t=new dn({props:{$$slots:{default:[de]},$$scope:{ctx:n}}}),{c(){an(t.$$.fragment)},m(n,a){sn(t,n,a),e=!0},p(n,[e]){const a={};268435456&e&&(a.$$scope={dirty:e,ctx:n}),t.$set(a)},i(n){e||(J(t.$$.fragment,n),e=!0)},o(n){Q(t.$$.fragment,n),e=!1},d(n){rn(t,n)}}}function ge(n){return[(n,t)=>n(t)]}class ve extends cn{constructor(n){super(),on(this,n,ge,he,c,{})}}function ke(t){let e,a,s;return a=new ve({}),{c(){e=y("main"),an(a.$$.fragment)},m(n,t){_(n,e,t),sn(a,e,null),s=!0},p:n,i(n){s||(J(a.$$.fragment,n),s=!0)},o(n){Q(a.$$.fragment,n),s=!1},d(n){n&&x(e),rn(a)}}}return new class extends cn{constructor(n){super(),on(this,n,null,ke,c,{})}}({target:document.body})}(); diff --git a/package.json b/package.json index 2c5b6fc..cd9c14e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "svelte-carousel", - "version": "1.0.8", + "version": "1.0.9", "description": "Svelte carousel", "main": "src/main.js", "author": "vadimkorr", diff --git a/src/components/Carousel/Carousel.svelte b/src/components/Carousel/Carousel.svelte index de433c5..7189513 100644 --- a/src/components/Carousel/Carousel.svelte +++ b/src/components/Carousel/Carousel.svelte @@ -11,6 +11,7 @@ removeResizeEventListener } from '../../utils/event' import { getAdjacentIndexes } from '../../utils/page' + import { get } from '../../utils/object' const dispatch = createEventDispatcher() @@ -52,7 +53,7 @@ export let autoplay = false /** - * Auto play change interval + * Auto play change interval (ms) */ export let autoplayDuration = 3000 @@ -71,6 +72,28 @@ */ export let dots = true + export function goTo(pageIndex, options) { + const animated = get(options, 'animated', true) + if (typeof pageIndex !== 'number') { + throw new Error('pageIndex should be a number') + } + showPage(pageIndex + Number(infinite), { offsetDelayMs: 0, animated }) + } + + export function goToPrev(options) { + const animated = get(options, 'animated', true) + showPrevPage({ + animated + }) + } + + export function goToNext(options) { + const animated = get(options, 'animated', true) + showNextPage({ + animated + }) + } + let store = createStore() let currentPageIndex = 0 $: originalCurrentPageIndex = currentPageIndex - Number(infinite); @@ -160,7 +183,7 @@ }) function handlePageChange(pageIndex) { - showPage(pageIndex + Number(infinite), { offsetDelay: 0, animated: true }) + showPage(pageIndex + Number(infinite), { offsetDelayMs: 0, animated: true }) } function offsetPage(animated) { @@ -168,42 +191,48 @@ offset = -currentPageIndex * pageWidth if (infinite) { if (currentPageIndex === 0) { - showPage(pagesCount - 2, { offsetDelay: duration, animated: false }) + showPage(pagesCount - 2, { offsetDelayMs: duration, animated: false }) } else if (currentPageIndex === pagesCount - 1) { - showPage(1, { offsetDelay: duration, animated: false }) + showPage(1, { offsetDelayMs: duration, animated: false }) } } } + // Disable page change while animation is in progress let disabled = false - function safeChangePage(cb) { + function safeChangePage(cb, options) { + const animated = get(options, 'animated', true) if (disabled) return cb() disabled = true setTimeout(() => { disabled = false - }, duration) + }, animated ? duration : 0) } - function showPage(pageIndex, { offsetDelay, animated }) { + function showPage(pageIndex, options) { + const animated = get(options, 'animated', true) + const offsetDelayMs = get(options, 'offsetDelayMs', true) safeChangePage(() => { store.moveToPage({ pageIndex, pagesCount }) setTimeout(() => { offsetPage(animated) - }, offsetDelay) - }) + }, offsetDelayMs) + }, { animated }) } - function showPrevPage() { + function showPrevPage(options) { + const animated = get(options, 'animated', true) safeChangePage(() => { store.prev({ infinite, pagesCount }) - offsetPage(true) - }) + offsetPage(animated) + }, { animated }) } - function showNextPage() { + function showNextPage(options) { + const animated = get(options, 'animated', true) safeChangePage(() => { store.next({ infinite, pagesCount }) - offsetPage(true) - }) + offsetPage(animated) + }, { animated }) } // gestures @@ -217,7 +246,7 @@ offset += event.detail.dx } function handleSwipeEnd() { - showPage(currentPageIndex, { offsetDelay: 0, animated: true }) + showPage(currentPageIndex, { offsetDelayMs: 0, animated: true }) } function handleFocused(event) { focused = event.detail.value diff --git a/src/components/Carousel/stories/Carousel.stories.js b/src/components/Carousel/stories/Carousel.stories.js index 5ba9029..6db130d 100644 --- a/src/components/Carousel/stories/Carousel.stories.js +++ b/src/components/Carousel/stories/Carousel.stories.js @@ -1,27 +1,33 @@ -import CarouselView from './CarouselView.svelte'; -import CarouselViewCustomDots from './CarouselViewCustomDots.svelte'; -import CarouselViewCustomArrows from './CarouselViewCustomArrows.svelte'; +import CarouselView from './CarouselView.svelte' +import CarouselViewCustomDots from './CarouselViewCustomDots.svelte' +import CarouselViewCustomArrows from './CarouselViewCustomArrows.svelte' +import CarouselViewMethods from './CarouselViewMethods.svelte' export default { title: 'Carousel', - component: CarouselView -}; + component: CarouselView, +} const Template = ({ ...args }) => ({ Component: CarouselView, - props: args -}); -export const Primary = Template.bind({}); + props: args, +}) +export const Primary = Template.bind({}) const TemplateCustomDots = ({ ...args }) => ({ Component: CarouselViewCustomDots, - props: args -}); -export const WithCustomDots = TemplateCustomDots.bind({}); + props: args, +}) +export const WithCustomDots = TemplateCustomDots.bind({}) const TemplateCustomArrows = ({ ...args }) => ({ Component: CarouselViewCustomArrows, - props: args -}); -export const WithCustomArrows = TemplateCustomArrows.bind({}); + props: args, +}) +export const WithCustomArrows = TemplateCustomArrows.bind({}) +const TemplateMethods = ({ ...args }) => ({ + Component: CarouselViewMethods, + props: args, +}) +export const WithMethods = TemplateMethods.bind({}) diff --git a/src/components/Carousel/stories/CarouselViewMethods.svelte b/src/components/Carousel/stories/CarouselViewMethods.svelte new file mode 100644 index 0000000..43c5803 --- /dev/null +++ b/src/components/Carousel/stories/CarouselViewMethods.svelte @@ -0,0 +1,88 @@ + + +++ + \ No newline at end of file diff --git a/src/docs/Carousel.svx b/src/docs/Carousel.svx index a3d5434..f79969d 100644 --- a/src/docs/Carousel.svx +++ b/src/docs/Carousel.svx @@ -186,6 +186,8 @@ ## Use case+ {#each colors as { color, text } (color)} + + +++ {/each} +{text}
++ carousel.goTo + + + + + carousel.goToPrev + + + + carousel.goToNext + + +++ + # Installation ```bash yarn add svelte-carousel @@ -202,7 +204,10 @@ Import component ``` + + # Props + | Prop | Type | Default | Description | @@ -220,7 +225,9 @@ Import component-# Event ++ +# Events ## `pageChange` Is dispatched on page change @@ -243,6 +250,8 @@ Is dispatched on page change ``` + + # Slots ## `prev` and `next` @@ -329,6 +338,101 @@ Slot props: +# Methods + +## `goTo` +Navigates to a page by index + +Arguments: + + + +| Argument | Type | Default | Description | +|--------------------|-------------|---------|---------------------------------------| +| `pageIndex` | `number` | | Page number | +| `options.animated` | `boolean` | `true` | Should it be animated or not | + ++ +```jsx + + ++ + + +``` + +## `goToPrev` +Navigates to the previous page + +Arguments: + ++ +| Argument | Type | Default | Description | +|--------------------|-------------|---------|---------------------------------------| +| `options.animated` | `boolean` | `true` | Should it be animated or not | + ++ +```jsx + + ++ + + +``` + +## `goToNext` +Navigates to the next page + +Arguments: + ++ +| Argument | Type | Default | Description | +|--------------------|-------------|---------|---------------------------------------| +| `options.animated` | `boolean` | `true` | Should it be animated or not | + ++ +```jsx + + ++ + + +``` + ++