mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-06-08 01:17:23 +08:00
2 lines
10 KiB
JavaScript
2 lines
10 KiB
JavaScript
import{t as z}from"./index-f1e7ee6d.js";import{l as de,m as me,n as pe,H as he,_ as ve}from"./index-c61a73ff.js";const we=()=>{window.cancelAnimationFrame=(()=>window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(r){return window.clearTimeout(r)})(),window.requestAnimationFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(r){return window.setTimeout(r,1e3/60)}}()},ye=(r,c)=>{if(r===c)return!0;if(r.length!==c.length)return!1;for(let l=0;l<r.length;++l)if(r[l]!==c[l])return!1;return!0};function X(){Array.isArray||(Array.isArray=function(a){return Object.prototype.toString.call(a)==="[object Array]"});let r,c,l,s,V,p,e=1,t=arguments[0]||{},f=!1,h=arguments.length;if(typeof t=="boolean"&&(f=t,t=arguments[1]||{},e++),typeof t!="object"&&typeof t!="function"&&(t={}),e===h)return t;for(;e<h;e++)if((c=arguments[e])!=null)for(r in c)l=t[r],s=c[r],V=Array.isArray(s),f&&s&&(typeof s=="object"||V)?(V?(V=!1,p=l&&Array.isArray(l)?l:[]):p=l&&typeof l=="object"?l:{},t[r]=X(f,p,s)):s!==void 0&&(t[r]=s);return t}const ge=Object.freeze(Object.defineProperty({__proto__:null,animationFrame:we,arrayEqual:ye,copyObj:X},Symbol.toStringTag,{value:"Module"})),Se=["innerHTML"],_e=Vue.defineComponent({name:"ReSeamlessScroll",__name:"index",props:{data:{type:Array},classOption:{type:Object}},emits:["scrollEnd"],setup(r,{expose:c,emit:l}){const s=r,{animationFrame:V,copyObj:p}=ge;V();const e=Vue.ref(0),t=Vue.ref(0),f=Vue.ref(0),h=Vue.ref(0),a=Vue.ref(0),v=Vue.ref(0),b=Vue.ref(0),k=Vue.ref("");let g=null,B=null,C=null,H=null,O=null,x=!1,T="ease-in";const{classOption:d}=s;d.key===void 0&&(d.key=0);const P=z(`wrap${d.key}`,null),j=z(`slotList${d.key}`,null),D=z(`realBox${d.key}`,null),q=Vue.computed(()=>Vue.unref(e)<0),R=Vue.computed(()=>Math.abs(Vue.unref(e))<Vue.unref(v)-Vue.unref(a)),G=Vue.computed(()=>({step:1,limitMoveNum:5,hoverStop:!0,direction:"top",openTouch:!0,singleHeight:0,singleWidth:0,waitTime:1e3,switchOffset:30,autoPlay:!0,navigation:!1,switchSingleStep:134,switchDelay:400,switchDisabledClass:"disabled",isSingleRemUnit:!1})),u=Vue.computed(()=>p({},Vue.unref(G),d)),J=Vue.computed(()=>Vue.unref(q)?"":Vue.unref(u).switchDisabledClass),K=Vue.computed(()=>Vue.unref(R)?"":Vue.unref(u).switchDisabledClass),Q=Vue.computed(()=>({position:"absolute",margin:`${Vue.unref(h)/2}px 0 0 -${Vue.unref(u).switchOffset}px`,transform:"translate(-100%,-50%)"})),Z=Vue.computed(()=>({position:"absolute",margin:`${Vue.unref(h)/2}px 0 0 ${Vue.unref(a)+Vue.unref(u).switchOffset}px`,transform:"translateY(-50%)"})),A=Vue.computed(()=>Vue.unref(u).direction!=="bottom"&&Vue.unref(u).direction!=="top"),W=Vue.computed(()=>Vue.unref(A)?{float:"left",overflow:"hidden"}:{overflow:"hidden"}),ee=Vue.computed(()=>({transform:`translate(${Vue.unref(e)}px,${Vue.unref(t)}px)`,transition:`all ${T} ${Vue.unref(f)}ms`,overflow:"hidden"})),E=Vue.computed(()=>Vue.unref(u).navigation),M=Vue.computed(()=>Vue.unref(E)?!1:Vue.unref(u).autoPlay),L=Vue.computed(()=>s.data.length>=Vue.unref(u).limitMoveNum),I=Vue.computed(()=>Vue.unref(u).hoverStop&&Vue.unref(M)&&Vue.unref(L)),N=Vue.computed(()=>Vue.unref(u).openTouch),Y=Vue.computed(()=>Vue.unref(u).isSingleRemUnit?parseInt(window.getComputedStyle(document.documentElement,null).fontSize):1),F=Vue.computed(()=>Vue.unref(u).singleWidth*Vue.unref(Y)),$=Vue.computed(()=>Vue.unref(u).singleHeight*Vue.unref(Y)),w=Vue.computed(()=>{let n;const o=Vue.unref(u).step;if(Vue.unref(A)?n=Vue.unref(F):n=Vue.unref($),n>0&&n%o>0)throw"如果设置了单步滚动,step需是单步大小的约数,否则无法保证单步滚动结束的位置是否准确";return o});function te(){e.value=0,t.value=0,S(),U()}function ne(){if(Vue.unref(q)){if(Math.abs(Vue.unref(e))<Vue.unref(u).switchSingleStep){e.value=0;return}e.value+=Vue.unref(u).switchSingleStep}}function ue(){if(Vue.unref(R)){if(Vue.unref(v)-Vue.unref(a)+Vue.unref(e)<Vue.unref(u).switchSingleStep){e.value=Vue.unref(a)-Vue.unref(v);return}e.value-=Vue.unref(u).switchSingleStep}}function S(){cancelAnimationFrame(B||"")}function oe(n){if(!Vue.unref(N))return;let o;const i=n.targetTouches[0],{waitTime:m,singleHeight:_,singleWidth:Ve}=Vue.unref(u);C={x:i.pageX,y:i.pageY},H=Vue.unref(t),O=Vue.unref(e),_&&Ve?(o&&clearTimeout(o),o=setTimeout(()=>{S()},m+20)):S()}function re(n){if(!Vue.unref(N)||n.targetTouches.length>1||n.scale&&n.scale!==1)return;const o=n.targetTouches[0],{direction:i}=Vue.unref(u),m={x:o.pageX-C.x,y:o.pageY-C.y};n.preventDefault();const _=Math.abs(m.x)<Math.abs(m.y)?1:0;_===1&&i==="bottom"||_===1&&i==="top"?t.value=H+m.y:(_===0&&i==="left"||_===0&&i==="right")&&(e.value=O+m.x)}function le(){if(!Vue.unref(N))return;let n;const o=Vue.unref(u).direction;if(f.value=50,o==="top")Vue.unref(t)>0&&(t.value=0);else if(o==="bottom"){const i=Vue.unref(b)/2*-1;Vue.unref(t)<i&&(t.value=i)}else if(o==="left")Vue.unref(e)>0&&(e.value=0);else if(o==="right"){const i=Vue.unref(v)*-1;Vue.unref(e)<i&&(e.value=i)}n&&clearTimeout(n),n=setTimeout(()=>{f.value=0,y()},Vue.unref(f))}function ie(){Vue.unref(I)&&ce()}function se(){Vue.unref(I)&&ae()}function y(){x||(B=requestAnimationFrame(function(){const n=Vue.unref(b)/2,o=Vue.unref(v)/2,{direction:i,waitTime:m}=Vue.unref(u);i==="top"?(Math.abs(Vue.unref(t))>=n&&(l("scrollEnd"),t.value=0),t.value-=w.value):i==="bottom"?(Vue.unref(t)>=0&&(l("scrollEnd"),t.value=n*-1),t.value+=w.value):i==="left"?(Math.abs(Vue.unref(e))>=o&&(l("scrollEnd"),e.value=0),e.value-=w.value):i==="right"&&(Vue.unref(e)>=0&&(l("scrollEnd"),e.value=o*-1),e.value+=w.value),g&&clearTimeout(g),Vue.unref($)?Math.abs(Vue.unref(t))%Vue.unref($)<Vue.unref(w)?g=setTimeout(()=>{y()},m):y():Vue.unref(F)&&Math.abs(Vue.unref(e))%Vue.unref(F)<Vue.unref(w)?g=setTimeout(()=>{y()},m):y()}))}function U(){Vue.nextTick(()=>{const{switchDelay:n}=Vue.unref(u);if(k.value="",Vue.unref(A)){h.value=Vue.unref(P).offsetHeight,a.value=Vue.unref(P).offsetWidth;let o=Vue.unref(j).offsetWidth;Vue.unref(M)&&(o=o*2+1),Vue.unref(D).style.width=o+"px",v.value=o}if(Vue.unref(M))T="ease-in",f.value=0;else{T="linear",f.value=n;return}Vue.unref(L)?(k.value=Vue.unref(j).innerHTML,setTimeout(()=>{var o;b.value=(o=Vue.unref(D))==null?void 0:o.offsetHeight,y()},0)):(S(),t.value=e.value=0)})}function ae(){x=!1,y()}function ce(){x=!0,g&&clearTimeout(g),S()}function fe(n){Vue.unref(u).direction==="left"||Vue.unref(u).direction==="right"||pe(()=>{n.deltaY>0?t.value-=w.value:t.value+=w.value},50)()}return de(()=>{U()}),me(()=>{S(),clearTimeout(g)}),c({reset:te}),(n,o)=>(Vue.openBlock(),Vue.createElementBlock("div",{ref:"wrap"+Vue.unref(d).key},[E.value?(Vue.openBlock(),Vue.createElementBlock("div",{key:0,style:Vue.normalizeStyle(Q.value),class:Vue.normalizeClass(J.value),onClick:ne},[Vue.renderSlot(n.$slots,"left-switch")],6)):Vue.createCommentVNode("",!0),E.value?(Vue.openBlock(),Vue.createElementBlock("div",{key:1,style:Vue.normalizeStyle(Z.value),class:Vue.normalizeClass(K.value),onClick:ue},[Vue.renderSlot(n.$slots,"right-switch")],6)):Vue.createCommentVNode("",!0),Vue.createElementVNode("div",{ref:"realBox"+Vue.unref(d).key,style:Vue.normalizeStyle(ee.value),onMouseenter:ie,onMouseleave:se,onTouchstartPassive:oe,onTouchmovePassive:re,onTouchend:le,onMousewheelPassive:fe},[Vue.createElementVNode("div",{ref:"slotList"+Vue.unref(d).key,style:Vue.normalizeStyle(W.value)},[Vue.renderSlot(n.$slots,"default")],4),Vue.createElementVNode("div",{innerHTML:k.value,style:Vue.normalizeStyle(W.value)},null,12,Se)],36)],512))}}),be=he(_e),ke=be,Ce=r=>(Vue.pushScopeId("data-v-28c9d5d1"),r=r(),Vue.popScopeId(),r),xe={class:"card-header"},Te=Ce(()=>Vue.createElementVNode("span",null,"无缝滚动示例",-1)),Ae={class:"item"},Ee=["textContent"],Me=Vue.defineComponent({name:"SeamlessScroll",__name:"index",setup(r){const c=Vue.ref(),l=Vue.ref([{title:"无缝滚动第一行无缝滚动第一行!!!!!!!!!!"},{title:"无缝滚动第二行无缝滚动第二行!!!!!!!!!!"},{title:"无缝滚动第三行无缝滚动第三行!!!!!!!!!!"},{title:"无缝滚动第四行无缝滚动第四行!!!!!!!!!!"},{title:"无缝滚动第五行无缝滚动第五行!!!!!!!!!!"},{title:"无缝滚动第六行无缝滚动第六行!!!!!!!!!!"},{title:"无缝滚动第七行无缝滚动第七行!!!!!!!!!!"},{title:"无缝滚动第八行无缝滚动第八行!!!!!!!!!!"},{title:"无缝滚动第九行无缝滚动第九行!!!!!!!!!!"}]),s=Vue.reactive({direction:"top"});function V(p){Vue.unref(c).reset(),Vue.unref(s).direction=p}return(p,e)=>{const t=Vue.resolveComponent("el-button"),f=Vue.resolveComponent("el-card"),h=Vue.resolveComponent("el-space");return Vue.openBlock(),Vue.createBlock(h,{wrap:""},{default:Vue.withCtx(()=>[Vue.createVNode(f,{class:"box-card",shadow:"never"},{header:Vue.withCtx(()=>[Vue.createElementVNode("div",xe,[Te,Vue.createVNode(t,{class:"button",link:"",type:"primary",onClick:e[0]||(e[0]=a=>V("top"))},{default:Vue.withCtx(()=>[Vue.createElementVNode("span",{style:Vue.normalizeStyle({color:s.direction==="top"?"red":""})}," 向上滚动 ",4)]),_:1}),Vue.createVNode(t,{class:"button",link:"",type:"primary",onClick:e[1]||(e[1]=a=>V("bottom"))},{default:Vue.withCtx(()=>[Vue.createElementVNode("span",{style:Vue.normalizeStyle({color:s.direction==="bottom"?"red":""})}," 向下滚动 ",4)]),_:1}),Vue.createVNode(t,{class:"button",link:"",type:"primary",onClick:e[2]||(e[2]=a=>V("left"))},{default:Vue.withCtx(()=>[Vue.createElementVNode("span",{style:Vue.normalizeStyle({color:s.direction==="left"?"red":""})}," 向左滚动 ",4)]),_:1}),Vue.createVNode(t,{class:"button",link:"",type:"primary",onClick:e[3]||(e[3]=a=>V("right"))},{default:Vue.withCtx(()=>[Vue.createElementVNode("span",{style:Vue.normalizeStyle({color:s.direction==="right"?"red":""})}," 向右滚动 ",4)]),_:1})])]),default:Vue.withCtx(()=>[Vue.createVNode(Vue.unref(ke),{ref_key:"scroll",ref:c,data:l.value,"class-option":s,class:"warp"},{default:Vue.withCtx(()=>[Vue.createElementVNode("ul",Ae,[(Vue.openBlock(!0),Vue.createElementBlock(Vue.Fragment,null,Vue.renderList(l.value,(a,v)=>(Vue.openBlock(),Vue.createElementBlock("li",{key:v},[Vue.createElementVNode("span",{class:"title",textContent:Vue.toDisplayString(a.title)},null,8,Ee)]))),128))])]),_:1},8,["data","class-option"])]),_:1})]),_:1})}}});const $e=ve(Me,[["__scopeId","data-v-28c9d5d1"]]);export{$e as default};
|