var S=Object.defineProperty;var X=(o,e,t)=>e in o?S(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var r=(o,e,t)=>X(o,typeof e!="symbol"?e+"":e,t);import{_ as x}from"./CDZLrDp2.js";import{_ as A}from"./C7hH4nwp.js";import{d as E,r as d,X as D,G as n,C as i,K as a,E as g,F as b,D as T,L as z,W as B,n as P,N as _,O as G,_ as $}from"./8WCqLz8P.js";import"./BOqWH9NE.js";const I={class:"cgtn_035"},N={class:"gallery"},V={key:0,class:"mask"},F=["data-index","onClick"],U=["href","target"],j={class:"title"},q={class:"date"},K={t:"1721814715081",class:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg","p-id":"1585",width:"200",height:"200"},O=["fill"],W=["fill"],H={style:{"user-select":"none"}},J={t:"1721814690734",class:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg","p-id":"13906",width:"200",height:"200"},Q=["fill"],R=["fill"],Y=E({__name:"cgtn_035",props:{disPlayLoop:{type:Boolean},cards:{},color:{},linkType:{default:"_self"},centerhref:{type:Boolean,default:!0},autoplay:{type:Boolean,default:!1}},setup(o){const e=o,t=d(1),c=d(null),f=d(null),v=d(null),y=d(null),m=(u,s)=>{window.open(u,e.linkType)};class C{constructor(s,l,h,p){r(this,"carouselContainer");r(this,"carouselControls");r(this,"carouselArray");r(this,"startX");r(this,"endX");r(this,"isMouseDown");r(this,"ifcenterhref");this.carouselContainer=s,this.carouselControls=l,this.carouselArray=Array.from(h),this.startX=0,this.endX=0,this.isMouseDown=!0,this.ifcenterhref=p,this.addSwipeListeners(),this.useControls(),this.updateGallery(),this.Autoplay()}updateGallery(){this.carouselArray.forEach(s=>{s.classList.remove("gallery-item-1","gallery-item-2","gallery-item-3","gallery-item-4","gallery-item-5")}),this.carouselArray.slice(0,5).forEach((s,l)=>{s.classList.add(`gallery-item-${l+1}`)})}setCurrentState(s){if(s==="previous"||typeof s!="string"&&s.classList.contains("prev")){if(e.disPlayLoop&&t.value===1)return;this.carouselArray.unshift(this.carouselArray.pop()),t.value<=1?t.value=e.cards.length:t.value--}else if(s==="next"||typeof s!="string"&&s.classList.contains("next")){if(e.disPlayLoop&&t.value===e.cards.length)return;this.carouselArray.push(this.carouselArray.shift()),t.value>=e.cards.length?t.value=1:t.value++}this.updateGallery()}useControls(){Array.from(this.carouselControls.children).forEach(l=>{l.addEventListener("click",h=>{h.preventDefault(),this.setCurrentState(l.classList.contains("prev")?"previous":"next")})})}addSwipeListeners(){console.log(this.ifcenterhref),this.ifcenterhref&&(this.carouselContainer.addEventListener("touchstart",this.handleTouchStart.bind(this),!1),this.carouselContainer.addEventListener("touchmove",this.handleTouchMove.bind(this),!1),this.carouselContainer.addEventListener("touchend",this.handleTouchEnd.bind(this),!1),this.carouselContainer.addEventListener("mousedown",this.handleMouseDown.bind(this),!1),this.carouselContainer.addEventListener("mousemove",this.handleMouseMove.bind(this),!1),this.carouselContainer.addEventListener("mouseup",this.handleMouseUp.bind(this),!1),this.carouselContainer.addEventListener("mouseleave",this.handleMouseLeave.bind(this),!1))}Autoplay(){console.log(e.autoplay),e.autoplay&&setInterval(()=>{e.disPlayLoop&&t.value===e.cards.length||(this.carouselArray.push(this.carouselArray.shift()),t.value>=e.cards.length?t.value=1:t.value++,this.updateGallery())},3e3)}handleTouchStart(s){this.startX=s.touches[0].clientX}handleTouchMove(s){this.endX=s.touches[0].clientX}handleTouchEnd(){this.handleSwipe()}handleMouseDown(s){this.isMouseDown=!0,this.startX=s.clientX}handleMouseMove(s){this.isMouseDown&&(this.endX=s.clientX)}handleMouseUp(){this.isMouseDown&&(this.isMouseDown=!1,this.handleSwipe())}handleMouseLeave(){this.isMouseDown&&(this.isMouseDown=!1)}handleSwipe(){if(this.startX!==this.endX){if(console.log(t.value,e.cards.length),this.startX-this.endX>50){if(e.disPlayLoop&&t.value===e.cards.length)return;this.setCurrentState("next")}else if(this.endX-this.startX>50){if(e.disPlayLoop&&t.value===1)return;this.setCurrentState("previous")}}}}D(()=>{!f.value||!v.value||(y.value=f.value.querySelectorAll(".gallery-item"),y.value&&(c.value=new C(f.value,v.value,y.value,e.centerhref)))});const w=()=>{c.value},L=()=>{c.value},k=()=>{c.value&&c.value.setCurrentState("previous")},M=()=>{c.value&&(console.log(2),c.value.setCurrentState("next"))};return(u,s)=>(n(),i("div",I,[a("div",N,[a("div",{class:"gallery-container",ref_key:"galleryContainer",ref:f},[u.centerhref?(n(),i("div",V)):g("",!0),u.centerhref?g("",!0):(n(),i("div",{key:1,class:"mask_left",onClick:k})),u.centerhref?g("",!0):(n(),i("div",{key:2,class:"mask_right",onClick:M})),(n(!0),i(b,null,T(e.cards,(l,h)=>{var p;return n(),i("div",{key:h,class:z(["gallery-item",`gallery-item-${h+1}`]),"data-index":h+1,style:B({"background-image":`url(${((p=l==null?void 0:l.photo)==null?void 0:p.thurm)||P(A)})`}),onClick:Z=>m(l.link)},[a("a",{class:"info",href:(l==null?void 0:l.link)||"javascript:void(0);",target:l.link?u.linkType:"_self"},[a("p",j,_(l.title),1),a("p",q,[G(x,{date:l.date},null,8,["date"])])],8,U)],14,F)}),128))],512),a("div",{class:"gallery-controls",ref_key:"galleryControlsContainer",ref:v},[a("div",{class:"prev",onClick:w},[(n(),i("svg",K,[a("path",{d:"M553.38 726.62L372.69 545.94c-18.72-18.72-18.72-49.16 0-67.88l180.69-180.69c12.5-12.5 32.75-12.5 45.25 0s12.5 32.75 0 45.25L429.25 512l169.38 169.38c12.5 12.5 12.5 32.75 0 45.25-6.25 6.25-14.44 9.38-22.62 9.38s-16.39-3.13-22.63-9.39zM417.62 523.31h0.31-0.31z",fill:e.color||"#ffffff","p-id":"1586"},null,8,O),a("path",{d:"M512 128c211.74 0 384 172.26 384 384S723.74 896 512 896 128 723.74 128 512s172.26-384 384-384m0-64C264.58 64 64 264.58 64 512s200.58 448 448 448 448-200.58 448-448S759.42 64 512 64z",fill:e.color||"#ffffff","p-id":"1587"},null,8,W)]))]),a("p",H,_(t.value)+" / "+_(e.cards.length),1),a("div",{class:"next",onClick:L},[(n(),i("svg",J,[a("path",{d:"M448 736c-8.19 0-16.38-3.12-22.62-9.38-12.5-12.5-12.5-32.75 0-45.25L594.75 512 425.38 342.62c-12.5-12.5-12.5-32.75 0-45.25s32.75-12.5 45.25 0l180.69 180.69c18.72 18.72 18.72 49.16 0 67.88l-180.7 180.68c-6.24 6.26-14.43 9.38-22.62 9.38z m158.06-212.69h0.31-0.31z",fill:e.color||"#ffffff","p-id":"13907"},null,8,Q),a("path",{d:"M512 128c211.74 0 384 172.26 384 384S723.74 896 512 896 128 723.74 128 512s172.26-384 384-384m0-64C264.58 64 64 264.58 64 512s200.58 448 448 448 448-200.58 448-448S759.42 64 512 64z",fill:e.color||"#ffffff","p-id":"13908"},null,8,R)]))])],512)])]))}}),re=$(Y,[["__scopeId","data-v-1b76be83"]]);export{re as default};

AltStyle によって変換されたページ (->オリジナル) /