vue-pure-admin/static/js/seamless-scroll-CbD7WipZ.js

2 lines
8.8 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import{d as ae,a as y,bh as V,p as r,u as e,bi as Ae,bj as Me,k as $,e as F,i as ie,g as w,v as le,s as S,O as Y,x as Oe,bk as Fe,V as $e,r as He,b as Pe,w as b,f as A,l as je,t as De,F as qe,h as H,j as Be,_ as Ee}from"./index-DI6gHrBb.js";const Re=()=>{window.cancelAnimationFrame=window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(a){return window.clearTimeout(a)},window.requestAnimationFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){return window.setTimeout(a,1e3/60)}}()},We=(a,d)=>{if(a===d)return!0;if(a.length!==d.length)return!1;for(let u=0;u<a.length;++u)if(a[u]!==d[u])return!1;return!0};function re(){Array.isArray||(Array.isArray=function(x){return Object.prototype.toString.call(x)==="[object Array]"});let a,d,u,f,p,m,l=1,t=arguments[0]||{},i=!1,v=arguments.length;if(typeof t=="boolean"&&(i=t,t=arguments[1]||{},l++),typeof t!="object"&&typeof t!="function"&&(t={}),l===v)return t;for(;l<v;l++)if((d=arguments[l])!=null)for(a in d)u=t[a],f=d[a],p=Array.isArray(f),i&&f&&(typeof f=="object"||p)?(p?(p=!1,m=u&&Array.isArray(u)?u:[]):m=u&&typeof u=="object"?u:{},t[a]=re(i,m,f)):f!==void 0&&(t[a]=f);return t}const ze=Object.freeze(Object.defineProperty({__proto__:null,animationFrame:Re,arrayEqual:We,copyObj:re},Symbol.toStringTag,{value:"Module"})),Le=["innerHTML"],Ne=ae({name:"ReSeamlessScroll",__name:"index",props:{data:{type:Array},classOption:{type:Object}},emits:["scrollEnd"],setup(a,{expose:d,emit:u}){const{animationFrame:f,copyObj:p}=ze;f();const m=a,l=u,t=y(0),i=y(0),v=y(0),x=y(0),h=y(0),k=y(0),P=y(0),j=y("");let C=null,I=null,D=null,U=null,X=null,q=!1,B="ease-in";m.classOption.key===void 0&&(m.classOption.key=0);const G=V(`wrap${m.classOption.key}`,null),J=V(`slotList${m.classOption.key}`,null),K=V(`realBox${m.classOption.key}`,null),Q=r(()=>e(t)<0),Z=r(()=>Math.abs(e(t))<e(k)-e(h)),ce=r(()=>({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})),o=r(()=>p({},e(ce),m.classOption)),ue=r(()=>e(Q)?"":e(o).switchDisabledClass),fe=r(()=>e(Z)?"":e(o).switchDisabledClass),me=r(()=>({position:"absolute",margin:`${e(x)/2}px 0 0 -${e(o).switchOffset}px`,transform:"translate(-100%,-50%)"})),de=r(()=>({position:"absolute",margin:`${e(x)/2}px 0 0 ${e(h)+e(o).switchOffset}px`,transform:"translateY(-50%)"})),E=r(()=>e(o).direction!=="bottom"&&e(o).direction!=="top"),ee=r(()=>e(E)?{float:"left",overflow:"hidden"}:{overflow:"hidden"}),pe=r(()=>({transform:`translate(${e(t)}px,${e(i)}px)`,transition:`all ${B} ${e(v)}ms`,overflow:"hidden"})),R=r(()=>e(o).navigation),W=r(()=>e(R)?!1:e(o).autoPlay),te=r(()=>m.data.length>=e(o).limitMoveNum),ne=r(()=>e(o).hoverStop&&e(W)&&e(te)),z=r(()=>e(o).openTouch),oe=r(()=>e(o).isSingleRemUnit?parseInt(window.getComputedStyle(document.documentElement,null).fontSize):1),L=r(()=>e(o).singleWidth*e(oe)),N=r(()=>e(o).singleHeight*e(oe)),_=r(()=>{let n;const s=e(o).step;if(e(E)?n=e(L):n=e(N),n>0&&n%s>0)throw"如果设置了单步滚动step需是单步大小的约数否则无法保证单步滚动结束的位置是否准确";return s});function ve(){t.value=0,i.value=0,M(),se()}function he(){if(e(Q)){if(Math.abs(e(t))<e(o).switchSingleStep){t.value=0;return}t.value+=e(o).switchSingleStep}}function we(){if(e(Z)){if(e(k)-e(h)+e(t)<e(o).switchSingleStep){t.value=e(h)-e(k);return}t.value-=e(o).switchSingleStep}}function M(){cancelAnimationFrame(I||"")}function ye(n){if(!e(z))return;let s;const c=n.targetTouches[0],{waitTime:g,singleHeight:O,singleWidth:Ce}=e(o);D={x:c.pageX,y:c.pageY},U=e(i),X=e(t),O&&Ce?(s&&clearTimeout(s),s=setTimeout(()=>{M()},g+20)):M()}function ge(n){if(!e(z)||n.targetTouches.length>1||n.scale&&n.scale!==1)return;const s=n.targetTouches[0],{direction:c}=e(o),g={x:s.pageX-D.x,y:s.pageY-D.y};n.preventDefault();const O=Math.abs(g.x)<Math.abs(g.y)?1:0;O===1&&c==="bottom"||O===1&&c==="top"?i.value=U+g.y:(O===0&&c==="left"||O===0&&c==="right")&&(t.value=X+g.x)}function be(){if(!e(z))return;let n;const s=e(o).direction;if(v.value=50,s==="top")e(i)>0&&(i.value=0);else if(s==="bottom"){const c=e(P)/2*-1;e(i)<c&&(i.value=c)}else if(s==="left")e(t)>0&&(t.value=0);else if(s==="right"){const c=e(k)*-1;e(t)<c&&(t.value=c)}n&&clearTimeout(n),n=setTimeout(()=>{v.value=0,T()},e(v))}function Se(){e(ne)&&Te()}function ke(){e(ne)&&_e()}function T(){q||(I=requestAnimationFrame(function(){const n=e(P)/2,s=e(k)/2,{direction:c,waitTime:g}=e(o);c==="top"?(Math.abs(e(i))>=n&&(l("scrollEnd"),i.value=0),i.value-=_.value):c==="bottom"?(e(i)>=0&&(l("scrollEnd"),i.value=n*-1),i.value+=_.value):c==="left"?(Math.abs(e(t))>=s&&(l("scrollEnd"),t.value=0),t.value-=_.value):c==="right"&&(e(t)>=0&&(l("scrollEnd"),t.value=s*-1),t.value+=_.value),C&&clearTimeout(C),e(N)?Math.abs(e(i))%e(N)<e(_)?C=setTimeout(()=>{T()},g):T():e(L)&&Math.abs(e(t))%e(L)<e(_)?C=setTimeout(()=>{T()},g):T()}))}function se(){Oe(()=>{const{switchDelay:n}=e(o);if(j.value="",e(E)){x.value=e(G).offsetHeight,h.value=e(G).offsetWidth;let s=e(J).offsetWidth;e(W)&&(s=s*2+1),e(K).style.width=s+"px",k.value=s}if(e(W))B="ease-in",v.value=0;else{B="linear",v.value=n;return}e(te)?(j.value=e(J).innerHTML,setTimeout(()=>{var s;P.value=(s=e(K))==null?void 0:s.offsetHeight,T()},0)):(M(),i.value=t.value=0)})}function _e(){q=!1,T()}function Te(){q=!0,C&&clearTimeout(C),M()}function xe(n){e(o).direction==="left"||e(o).direction==="right"||Fe(()=>{n.deltaY>0?i.value-=_.value:i.value+=_.value},50)()}return Ae(()=>{se()}),Me(()=>{M(),clearTimeout(C)}),d({reset:ve}),(n,s)=>(F(),$("div",{ref:"wrap"+a.classOption.key},[R.value?(F(),$("div",{key:0,style:S(me.value),class:le(ue.value),onClick:he},[Y(n.$slots,"left-switch")],6)):ie("",!0),R.value?(F(),$("div",{key:1,style:S(de.value),class:le(fe.value),onClick:we},[Y(n.$slots,"right-switch")],6)):ie("",!0),w("div",{ref:"realBox"+a.classOption.key,style:S(pe.value),onMouseenter:Se,onMouseleave:ke,onTouchstartPassive:ye,onTouchmovePassive:ge,onTouchend:be,onMousewheelPassive:xe},[w("div",{ref:"slotList"+a.classOption.key,style:S(ee.value)},[Y(n.$slots,"default")],4),w("div",{style:S(ee.value),innerHTML:j.value},null,12,Le)],36)],512))}}),Ve=$e(Ne),Ye={class:"card-header"},Ie={class:"item"},Ue=["textContent"],Xe=ae({name:"SeamlessScroll",__name:"seamless-scroll",setup(a){const d=y(),u=y([{title:"无缝滚动第一行无缝滚动第一行!!!!!!!!!!"},{title:"无缝滚动第二行无缝滚动第二行!!!!!!!!!!"},{title:"无缝滚动第三行无缝滚动第三行!!!!!!!!!!"},{title:"无缝滚动第四行无缝滚动第四行!!!!!!!!!!"},{title:"无缝滚动第五行无缝滚动第五行!!!!!!!!!!"},{title:"无缝滚动第六行无缝滚动第六行!!!!!!!!!!"},{title:"无缝滚动第七行无缝滚动第七行!!!!!!!!!!"},{title:"无缝滚动第八行无缝滚动第八行!!!!!!!!!!"},{title:"无缝滚动第九行无缝滚动第九行!!!!!!!!!!"}]),f=He({direction:"top"});function p(m){e(d).reset(),e(f).direction=m}return(m,l)=>{const t=H("el-button"),i=H("el-link"),v=H("el-card"),x=H("el-space");return F(),Pe(x,{wrap:""},{default:b(()=>[A(v,{class:"box-card",shadow:"never"},{header:b(()=>[w("div",Ye,[l[4]||(l[4]=w("span",{class:"font-medium"},"无缝滚动",-1)),A(t,{class:"button",link:"",type:"primary",onClick:l[0]||(l[0]=h=>p("top"))},{default:b(()=>[w("span",{style:S({color:f.direction==="top"?"red":""})}," 向上滚动 ",4)]),_:1}),A(t,{class:"button",link:"",type:"primary",onClick:l[1]||(l[1]=h=>p("bottom"))},{default:b(()=>[w("span",{style:S({color:f.direction==="bottom"?"red":""})}," 向下滚动 ",4)]),_:1}),A(t,{class:"button",link:"",type:"primary",onClick:l[2]||(l[2]=h=>p("left"))},{default:b(()=>[w("span",{style:S({color:f.direction==="left"?"red":""})}," 向左滚动 ",4)]),_:1}),A(t,{class:"button",link:"",type:"primary",onClick:l[3]||(l[3]=h=>p("right"))},{default:b(()=>[w("span",{style:S({color:f.direction==="right"?"red":""})}," 向右滚动 ",4)]),_:1})]),A(i,{class:"mt-2",href:"https://github.com/pure-admin/vue-pure-admin/blob/main/src/views/components/seamless-scroll.vue",target:"_blank"},{default:b(()=>l[5]||(l[5]=[Be(" 代码位置 src/views/components/seamless-scroll.vue ")])),_:1})]),default:b(()=>[A(e(Ve),{ref_key:"scroll",ref:d,data:u.value,"class-option":f,class:"warp"},{default:b(()=>[w("ul",Ie,[(F(!0),$(qe,null,je(u.value,(h,k)=>(F(),$("li",{key:k},[w("span",{class:"title",textContent:De(h.title)},null,8,Ue)]))),128))])]),_:1},8,["data","class-option"])]),_:1})]),_:1})}}}),Je=Ee(Xe,[["__scopeId","data-v-ff2abade"]]);export{Je as default};