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

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