@fox-js/navigation 4.0.1-15 → 4.0.1-16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +2 -2
- package/dist/index.esm.js +256 -243
- package/dist/index.umd.js +2 -2
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use strict";/*!
|
|
2
|
-
* @fox-js/navigation v4.0.1-
|
|
3
|
-
*/const s=require("vue"),b=require("@fox-js/fox"),k=s.defineComponent({__name:"index",props:{routerViewName:{},transition:{type:[Function,Boolean],default:!1}},setup(t){return(e,n)=>{const o=s.resolveComponent("fox-router-view");return s.openBlock(),s.createBlock(o,{class:"fox-card-navigator","view-class":"fox-card-navigator__item","view-active-class":"fox-card-navigator__item-active","view-inactive-class":"fox-card-navigator__item-inactive","transition-name":"fox-card-navigator__trans",transition:e.transition,multi:!0,name:e.routerViewName},null,8,["transition","name"])}}}),F=Object.freeze(Object.defineProperty({__proto__:null,default:k},Symbol.toStringTag,{value:"Module"})),U=s.defineComponent({__name:"index",props:{routerViewName:{},transition:{type:[Function,Boolean],default:!0}},setup(t){return(e,n)=>{const o=s.resolveComponent("fox-router-view");return s.openBlock(),s.createBlock(o,{transition:!1,multi:!1,name:e.routerViewName},{default:s.withCtx(({Component:i})=>[s.createVNode(s.Transition,{name:"fox-default-navigator__trans"},{default:s.withCtx(()=>[(s.openBlock(),s.createBlock(s.resolveDynamicComponent(i)))]),_:2},1024)]),_:1},8,["name"])}}}),j=Object.freeze(Object.defineProperty({__proto__:null,default:U},Symbol.toStringTag,{value:"Module"})),S=10;function q(t,e){return t>e&&t>S?"horizontal":e>t&&e>S?"vertical":""}function V(){const t={startX:0,startY:0,startTime:0,duration:0,moveX:0,moveY:0,deltaX:0,deltaY:0,offsetX:0,offsetY:0,direction:""},e=()=>t.direction==="vertical",n=()=>t.direction==="horizontal",o=()=>{t.deltaX=0,t.deltaY=0,t.offsetX=0,t.offsetY=0,t.direction="",t.startTime=0};return{move:m=>{if(m.touches){const a=m.touches[0];t.deltaX=a.clientX-t.startX,t.deltaY=a.clientY-t.startY,t.moveX=a.clientX,t.moveY=a.clientY}else t.deltaX=m.clientX-t.startX,t.deltaY=m.clientY-t.startY,t.moveX=m.clientX,t.moveY=m.clientY;t.offsetX=Math.abs(t.deltaX),t.offsetY=Math.abs(t.deltaY),t.duration=Date.now()-t.startTime,t.direction||(t.direction=q(t.offsetX,t.offsetY))},start:m=>{if(o(),m.touches){const a=m.touches[0];t.startX=a.clientX,t.startY=a.clientY}else t.startX=m.clientX,t.startY=m.clientY;t.startTime=Date.now()},reset:o,isVertical:e,isHorizontal:n,state:t}}function H(t){return t===window}const G=t=>{const e=s.unref(t);if(H(e)){const n=e.innerWidth,o=e.innerHeight;return{top:0,left:0,right:n,bottom:o,width:n,height:o}}return e&&e.getBoundingClientRect?e.getBoundingClientRect():{top:0,left:0,right:0,bottom:0,width:0,height:0}},J=(t,e,n)=>{e=e??{bubbles:!1,cancelable:!1,detail:void 0};const o=document.createEvent("Events");let i=!0,d=!0;for(let a in e)a==="bubbles"?i=!!e[a]:a==="cancelable"?d=!!e[a]:o[a]=e[a];o.initEvent(t,i,d),(n??document).dispatchEvent(o)},K=15,Q=300,Z=200;function tt(t){t.stopPropagation()}function et(t,e,n=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*n}function P(t,e=0,n,o=Z){n==="end"?t.style.transition=`transform ${o}ms linear`:t.style.transition="transform 0ms linear",t.style.transform=`translate3d(${e}px, 0, 0)`}function A(t){t.style.transition="",t.style.transform=""}const nt=/^matrix\((.+)\)$/;function C(t){let e=0;const n=t,{transform:o}=window.getComputedStyle(n);if(o){const i=nt.exec(o);i&&(e=+i[1].split(/,\s*/)[4])}return e}const X=new WeakMap;function ot(t,e,n,o,i,d=600,m=60){const a={active:!0,startDistance:0,scrollDistance:0,scrollTime:0,moving:!1,transitionEndTrigger:null},x=t.previousSibling,f=V(),g=(_,h,c,T)=>{let v=h+a.startDistance;if(c==="end"){const D=G(_);let l=D.width*e;v<l?v=0:v=D.width,a.transitionEndTrigger=()=>{a.moving=!1,i&&_.classList.remove(i),setTimeout(()=>{x&&A(x),v==0?A(_):J(b.FoxLeaveEnd,{},_),a.moving=!1},m)},x&&P(x,0,"",0),v>0&&typeof o=="function"&&o(),P(_,v,"end",T)}else v<0&&(v=0),P(_,v,"",0)},w=()=>{a.transitionEndTrigger&&(a.transitionEndTrigger(),a.transitionEndTrigger=null)},r=_=>{f.start(_),a.scrollDistance=0,a.moving&&(a.scrollDistance=C(t)),i&&t.classList.add(i),a.transitionEndTrigger=null,a.moving=!0},p=_=>{a.moving=!0,f.move(_),!(f.isVertical()||C(t)===0&&f.state.deltaX<0)&&(tt(_),g(t,f.state.deltaX,"",0))},u=()=>{if(f.isVertical()||C(t)===0&&f.state.deltaX<0)return;const h=f.state.deltaX;if(h===0){i&&t.classList.remove(i),a.moving=!1;return}const c=f.state.duration;if(c<Q&&Math.abs(h)>K){const v=et(h,c,n);g(t,v,"end",d)}else g(t,h,"end",d)};t.addEventListener("transitionend",w),t.addEventListener("transitioncancel",w),t.addEventListener("touchstart",r),t.addEventListener("touchmove",p),t.addEventListener("touchend",u),t.addEventListener("touchcancel",u),X.set(t,{state:a,transitionend:w,transitioncancel:w,touchstart:r,touchmove:p,touchend:u,touchcancel:u})}function it(t){const e=X.get(t);e&&(X.delete(t),t.addEventListener("transitionend",e.transitionend),t.addEventListener("transitioncancel",e.transitioncancel),t.addEventListener("touchstart",e.touchstart),t.addEventListener("touchmove",e.touchmove),t.addEventListener("touchend",e.touchend),t.addEventListener("touchcancel",e.touchcancel))}const st=s.defineComponent({__name:"index",props:{dragRemove:{type:Boolean,default:!0},removeViewPage:{},removeMoveRatio:{default:.5},momentumReduceRatio:{default:1},resetDelay:{default:120},swipeDuration:{default:60},routerViewName:{},viewTag:{type:[Function,String],default:"div"},transition:{type:[Function,Boolean],default:!0},viewClass:{type:[Function,String],default:"fox-root-navigator__item"}},setup(t){const e=t;let n=null,o=null;function i(r){return(r.params&&r.params.animationType)??"slide"}function d(r){return(r.params&&r.params.dragRemove)??e.dragRemove}const m=(r,p,u,_)=>{if(u.opsType===b.OperationType.Append||p){const h=i(u),c=p?"show":"enter";if(c==="show"&&(h==="pop"||o!=="leave"||(n?i(n):"")==="pop"))return;c==="enter"&&(n=u,o="enter");const T=`fox-root-navigator__${h}-${c}-from`,v=`fox-root-navigator__${h}-${c}-active`;r.classList.add(T),r.classList.add(v)}},a=(r,p,u,_)=>{if(u.opsType===b.OperationType.Append||p){const h=i(u),c=p?"show":"enter";if(c==="show"&&(h==="pop"||o!=="leave"||(n?i(n):"")==="pop"))return;const T=`fox-root-navigator__${h}-${c}-from`,v=`fox-root-navigator__${h}-${c}-to`;r.classList.remove(T),r.classList.add(v)}},x=(r,p,u,_)=>{if(u.opsType===b.OperationType.Append||p){const c=i(u),T=p?"show":"enter";if(T==="enter"&&(n=null,o=null),c!=="pop"){const v=`fox-root-navigator__${c}-${T}-active`,D=`fox-root-navigator__${c}-${T}-to`;r.classList.remove(v),r.classList.remove(D)}}d(u)===!0&&!p&&u.opsType===b.OperationType.Append&&ot(r,e.removeMoveRatio,e.momentumReduceRatio,e.removeViewPage,"fox-root-navigator__item-moving",e.swipeDuration,e.resetDelay)},f=(r,p,u,_)=>{if(u.opsType===b.OperationType.Append||p){const h=i(u),c=p?"hide":"leave";if(c==="hide"&&(h==="pop"||o!=="enter"||(n?i(n):"")==="pop"))return;c==="leave"&&(n=u,o="leave");const T=`fox-root-navigator__${h}-${c}-from`,v=`fox-root-navigator__${h}-${c}-active`;r.classList.add(T),r.classList.add(v)}},g=(r,p,u,_)=>{if(u.opsType===b.OperationType.Append||p){const h=i(u),c=p?"hide":"leave";if(c==="hide"&&(h==="pop"||o!=="enter"||(n?i(n):"")==="pop"))return;const T=`fox-root-navigator__${h}-${c}-from`,v=`fox-root-navigator__${h}-${c}-to`;r.classList.remove(T),r.classList.add(v)}},w=(r,p,u,_)=>{if(u.opsType===b.OperationType.Append||p){const c=i(u),T=p?"hide":"leave";if(T==="leave"&&(n=null,o=null),c!=="pop"){const v=`fox-root-navigator__${c}-${T}-active`,D=`fox-root-navigator__${c}-${T}-to`;r.classList.remove(v),r.classList.remove(D)}}d(u)&&!p&&it(r)};return(r,p)=>{const u=s.resolveComponent("fox-router-view");return s.openBlock(),s.createBlock(u,{class:"fox-root-navigator","view-class":r.viewClass,"before-enter":m,enter:a,"after-enter":x,"before-leave":f,leave:g,"after-leave":w,multi:!0,name:r.routerViewName,"view-tag":r.viewTag,transition:r.transition},null,8,["view-class","name","view-tag","transition"])}}}),at=Object.freeze(Object.defineProperty({__proto__:null,default:st},Symbol.toStringTag,{value:"Module"})),rt={class:"fox-swiper-navigator"},ct=s.defineComponent({__name:"swiper",props:{width:{},scrollDistance:{},scrollDuration:{},direction:{}},setup(t){const e=t,n=s.computed(()=>{const o={transform:`translate3d(${e.scrollDistance}px, 0, 0)`,width:`${e.width}`};return e.scrollDuration>0&&(o["transition-duration"]=`${e.scrollDuration}ms`),o});return(o,i)=>(s.openBlock(),s.createElementBlock("div",rt,[s.createElementVNode("div",{class:"fox-swiper-navigator__inner",style:s.normalizeStyle(n.value)},[s.renderSlot(o.$slots,"default")],4)]))}});let lt=0;function ut(){return++lt}const dt=15,ft=300,ht=200;function mt(t){t.stopPropagation()}function pt(t,e,n=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*n}function I(t,e=0,n,o=ht){n==="end"?t.style.transition=`transform ${o}ms linear`:t.style.transition="transform 0ms linear",t.style.transform=`translate3d(${e}px, 0, 0)`}class vt{width=0;columnWidth=0;max=0;min=0;el=null;swipeDuration=360;transitionEndTrigger=null;moving=!1;startDistance=0;scrollDistance=0;getStartDistance;openPage;isPageOpened;pageOpened;moveRatio=.5;momentumReduceRatio=1;transitionend=null;touchstart=null;touchmove=null;touchend=null;touchcancel=null;constructor(e,n,o,i,d,m){this.getStartDistance=e,this.openPage=n,this.isPageOpened=o,this.pageOpened=i,this.moveRatio=d,this.momentumReduceRatio=m}open(){const e=this.el,n=V(),o=(i,d,m,a)=>{let x=d+this.startDistance;const f=this.columnWidth*this.moveRatio;if(m==="end"){if(d==0){this.moving=!1;return}Math.abs(d)>f?d>0?x=this.startDistance+this.columnWidth:x=this.startDistance-this.columnWidth:x=this.startDistance;let g=-x;g<0?g=0:g>this.width-this.columnWidth&&(g=this.width-this.columnWidth);const w=Math.floor(g/this.columnWidth);this.isPageOpened(w)||this.openPage(w),x=-w*this.columnWidth,a&&a>0&&(this.transitionEndTrigger=()=>{this.moving=!1,this.pageOpened(w)}),I(i,x,"end",a),this.scrollDistance=x}else{if(Math.abs(d)>f){let w=0;if(d>0?w=Math.abs(this.startDistance+this.columnWidth):w=Math.abs(this.startDistance-this.columnWidth),w>=0&&w<this.width){const r=Math.floor(w/this.columnWidth);this.isPageOpened(r)||this.openPage(r)}}let g=-x;g<this.min?g=this.min:g>this.max&&(g=this.max),I(i,-g,"",0)}};this.transitionend=()=>{e.style.transition="",this.transitionEndTrigger&&(this.transitionEndTrigger(),this.transitionEndTrigger=null)},this.touchstart=i=>{this.moving||(n.start(i),this.startDistance=this.getStartDistance(),this.transitionEndTrigger=null,this.moving=!0)},this.touchmove=i=>{n.move(i),!n.isVertical()&&(mt(i),o(e,n.state.deltaX,"",0))},this.touchend=()=>{if(n.isVertical())return;const i=n.state.deltaX;if(i==0)return;const d=n.state.duration;if(d<ft&&Math.abs(i)>dt){const a=pt(i,d,this.momentumReduceRatio);o(e,a,"end",this.swipeDuration)}else o(e,i,"end",this.swipeDuration)},e.addEventListener("transitionend",this.transitionend),e.addEventListener("touchstart",this.touchstart),e.addEventListener("touchmove",this.touchmove),e.addEventListener("touchend",this.touchend),e.addEventListener("touchcancel",this.touchend)}close(){const e=this.el;this.transitionend&&e.addEventListener("transitionend",this.transitionend),this.touchstart&&e.addEventListener("touchstart",this.touchstart),this.touchmove&&e.addEventListener("touchmove",this.touchmove),this.touchend&&e.addEventListener("touchend",this.touchend),this.touchcancel&&e.addEventListener("touchcancel",this.touchcancel),this.el=null}}function gt(t,e,n,o,i,d){return new vt(t,e,n,o,i,d)}function _t(t){const e=s.unref(t),n=window.getComputedStyle(e,null),o=parseFloat(n.getPropertyValue("padding-left")),i=parseFloat(n.getPropertyValue("padding-right")),d=parseFloat(n.getPropertyValue("padding-top")),m=parseFloat(n.getPropertyValue("padding-bottom"));return{width:e.clientWidth-o-i,height:e.clientHeight-d-m}}const wt=s.defineComponent({__name:"index",props:{activePath:{},routes:{},height:{default:-1},width:{default:-1},draggable:{type:Boolean,default:!0},openViewPage:{},routerViewName:{},moveRatio:{default:.5},momentumReduceRatio:{default:1},direction:{default:"horizontal"},transition:{type:[Function,Boolean],default:!0},swipeDuration:{default:360},scrollDuration:{},customClass:{},customStyle:{}},emits:["update:activePath"],setup(t,{emit:e}){const n=t,o=s.reactive({scrollDistance:0,index:-1,openedIndexList:[],width:n.width,height:n.height}),i=e,d=()=>o.scrollDistance,m=l=>{if(o.openedIndexList.indexOf(l)===-1){o.openedIndexList.push(l);const E=n.routes[l];try{n.openViewPage(E,l)}catch(y){console.error(y)}}},a=l=>o.openedIndexList.indexOf(l)!==-1,x=l=>{o.index=l,o.width>0?o.scrollDistance=-o.index*o.width:o.scrollDistance=0;const E=n.routes[l];i("update:activePath",E.path)};let f=null;n.draggable&&(f=gt(d,m,a,x,n.moveRatio,n.momentumReduceRatio));let g=null;s.onMounted(()=>{const l=h(),E=()=>{const y=_t(l);w(n.activePath,n.routes,y.width,y.height,n.swipeDuration,n.direction)};if(window.ResizeObserver&&(g=new window.ResizeObserver(E),g.observe(l)),E(),f){const y=T();f.el=y,f.open()}}),s.onBeforeUnmount(()=>{g&&(g.disconnect(),g=null),f&&f.close()}),s.watch([()=>n.activePath,()=>n.routes,()=>n.width,()=>n.height,()=>n.swipeDuration,()=>n.direction],([l,E,y,$,M,R])=>{const O=y<=0?o.width:y,L=$<=0?o.height:$;w(l,E,O,L,M,R)});const w=(l,E,y,$,M,R="horizontal")=>{const O=l;if(o.index=E.findIndex(L=>L.path===O),R==="horizontal"){const L=y;if(L>0){o.width=y;const z=L*n.routes.length,W=-L/3,N=L*(E.length-1)+L/3;f&&(f.columnWidth=L,f.width=z,f.min=W,f.max=N),o.index!==-1&&(o.openedIndexList.push(o.index),o.scrollDistance=-L*o.index)}}f&&(f.swipeDuration=M)},r=`fox-swiper-navigator-${ut()}`,p=s.computed(()=>{const l=[r];return n.customClass&&l.push(n.customClass),l}),u=s.computed(()=>{const l={},E=o.width>0?o.width:n.width;E>0&&(l.width=`${E}px`);const y=o.height>0?o.height:n.height;return y>0&&(l.height=`${y}px`),n.customStyle&&Object.assign(l,n.customStyle),l});let _=null;function h(){return _||(_=document.querySelector(`.${r}`),_)}let c=null;function T(){return c||(c=document.querySelector(`.${r}>.fox-swiper-navigator__inner`),c)}const v=s.computed(()=>o.width>0?`${o.width*n.routes.length}px`:"100%"),D=(l,E)=>{const y=n.routes.findIndex($=>{const M=l.path??l.name??"";return $.path==M});return o.width<=0?{}:{style:{left:`${y*o.width}px`,width:`${o.width}px`}}};return(l,E)=>{const y=s.resolveComponent("fox-router-view");return s.openBlock(),s.createBlock(y,{class:s.normalizeClass(p.value),style:s.normalizeStyle(u.value),"view-class":"fox-swiper-navigator__item",tag:ct,"view-tag-props":D,multi:!0,name:l.routerViewName,transition:l.transition,"scroll-distance":o.scrollDistance,"scroll-duration":l.scrollDuration,direction:l.direction,width:v.value},null,8,["class","style","name","transition","scroll-distance","scroll-duration","direction","width"])}}}),Tt=Object.freeze(Object.defineProperty({__proto__:null,default:wt},Symbol.toStringTag,{value:"Module"}));let yt="fox-";const xt=[],B=Object.assign({"/src/components/card-navigator/index.vue":F,"/src/components/default-navigator/index.vue":j,"/src/components/root-navigator/index.vue":at,"/src/components/swiper-navigator/index.vue":Tt}),Y=[];for(const t in B){let e=/src\/components\/(.*)\/index.vue/.exec(t)[1];xt.indexOf(e)===-1&&Y.push({name:e,component:B[t].default})}const Et={install(t){Y.forEach(e=>{t.component(`${yt}${e.name}`,e.component)})}};module.exports=Et;
|
|
2
|
+
* @fox-js/navigation v4.0.1-15 Sat Jun 15 2024 16:18:22 GMT+0800 (中国标准时间)
|
|
3
|
+
*/const r=require("vue"),L=require("@fox-js/fox"),k=r.defineComponent({__name:"index",props:{routerViewName:{},transition:{type:[Function,Boolean],default:!1}},setup(t){return(e,n)=>{const o=r.resolveComponent("fox-router-view");return r.openBlock(),r.createBlock(o,{class:"fox-card-navigator","view-class":"fox-card-navigator__item","view-active-class":"fox-card-navigator__item-active","view-inactive-class":"fox-card-navigator__item-inactive","transition-name":"fox-card-navigator__trans",transition:e.transition,multi:!0,name:e.routerViewName},null,8,["transition","name"])}}}),F=Object.freeze(Object.defineProperty({__proto__:null,default:k},Symbol.toStringTag,{value:"Module"})),U=r.defineComponent({__name:"index",props:{routerViewName:{},transition:{type:[Function,Boolean],default:!0}},setup(t){return(e,n)=>{const o=r.resolveComponent("fox-router-view");return r.openBlock(),r.createBlock(o,{transition:!1,multi:!1,name:e.routerViewName},{default:r.withCtx(({Component:i})=>[r.createVNode(r.Transition,{name:"fox-default-navigator__trans"},{default:r.withCtx(()=>[(r.openBlock(),r.createBlock(r.resolveDynamicComponent(i)))]),_:2},1024)]),_:1},8,["name"])}}}),j=Object.freeze(Object.defineProperty({__proto__:null,default:U},Symbol.toStringTag,{value:"Module"})),C=10;function q(t,e){return t>e&&t>C?"horizontal":e>t&&e>C?"vertical":""}function B(){const t={startX:0,startY:0,startTime:0,duration:0,moveX:0,moveY:0,deltaX:0,deltaY:0,offsetX:0,offsetY:0,direction:""},e=()=>t.direction==="vertical",n=()=>t.direction==="horizontal",o=()=>{t.deltaX=0,t.deltaY=0,t.offsetX=0,t.offsetY=0,t.direction="",t.startTime=0};return{move:p=>{if(p.touches){const m=p.touches[0];t.deltaX=m.clientX-t.startX,t.deltaY=m.clientY-t.startY,t.moveX=m.clientX,t.moveY=m.clientY}else t.deltaX=p.clientX-t.startX,t.deltaY=p.clientY-t.startY,t.moveX=p.clientX,t.moveY=p.clientY;t.offsetX=Math.abs(t.deltaX),t.offsetY=Math.abs(t.deltaY),t.duration=Date.now()-t.startTime,t.direction||(t.direction=q(t.offsetX,t.offsetY))},start:p=>{if(o(),p.touches){const m=p.touches[0];t.startX=m.clientX,t.startY=m.clientY}else t.startX=p.clientX,t.startY=p.clientY;t.startTime=Date.now()},reset:o,isVertical:e,isHorizontal:n,state:t}}function H(t){return t===window}const G=t=>{const e=r.unref(t);if(H(e)){const n=e.innerWidth,o=e.innerHeight;return{top:0,left:0,right:n,bottom:o,width:n,height:o}}return e&&e.getBoundingClientRect?e.getBoundingClientRect():{top:0,left:0,right:0,bottom:0,width:0,height:0}},J=(t,e,n)=>{e=e??{bubbles:!1,cancelable:!1,detail:void 0};const o=document.createEvent("Events");let i=!0,h=!0;for(let m in e)m==="bubbles"?i=!!e[m]:m==="cancelable"?h=!!e[m]:o[m]=e[m];o.initEvent(t,i,h),(n??document).dispatchEvent(o)},K=15,Q=300,Z=200;function tt(t){t.stopPropagation()}function et(t,e,n=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*n}function A(t,e=0,n,o=Z){n==="end"?t.style.transition=`transform ${o}ms linear`:t.style.transition="transform 0ms linear",t.style.transform=`translate3d(${e}px, 0, 0)`}function S(t){t.style.transition="",t.style.transform=""}const nt=/^matrix\((.+)\)$/;function P(t){let e=0;const n=t,{transform:o}=window.getComputedStyle(n);if(o){const i=nt.exec(o);i&&(e=+i[1].split(/,\s*/)[4])}return e}const X=new WeakMap;function ot(t,e,n,o,i,h=600,p=60,m=null){const l={active:!0,startDistance:0,scrollDistance:0,scrollTime:0,moving:!1,dragging:!1,transitionEndTrigger:null},_=t.previousSibling,u=B(),y=(d,a,v,E)=>{let w=a+l.startDistance;if(v==="end"){const c=G(d);let T=c.width*e;w<T?w=0:w=c.width,l.transitionEndTrigger=()=>{l.moving=!1,i&&d.classList.remove(i),setTimeout(()=>{_&&S(_),w==0?S(d):J(L.FoxLeaveEnd,{},d),l.moving=!1},p)},_&&A(_,0,"",0),w>0&&typeof o=="function"&&o(),A(d,w,"end",E)}else w<0&&(w=0),A(d,w,"",0)},s=()=>{l.transitionEndTrigger&&(l.transitionEndTrigger(),l.transitionEndTrigger=null)},g=d=>{if(u.start(d),l.draging=m?m(t,u.state.startX,u.state.startY):!0,!l.draging){u.reset();return}l.scrollDistance=0,l.moving&&(l.scrollDistance=P(t)),i&&t.classList.add(i),l.transitionEndTrigger=null,l.moving=!0},f=d=>{!l.draging||(l.moving=!0,u.move(d),u.isVertical())||P(t)===0&&u.state.deltaX<0||(tt(d),y(t,u.state.deltaX,"",0))},b=()=>{if(!l.draging||(l.draging=!1,u.isVertical())||P(t)===0&&u.state.deltaX<0)return;const a=u.state.deltaX;if(a===0){i&&t.classList.remove(i),l.moving=!1;return}const v=u.state.duration;if(v<Q&&Math.abs(a)>K){const w=et(a,v,n);y(t,w,"end",h)}else y(t,a,"end",h)};t.addEventListener("transitionend",s),t.addEventListener("transitioncancel",s),t.addEventListener("touchstart",g),t.addEventListener("touchmove",f),t.addEventListener("touchend",b),t.addEventListener("touchcancel",b),X.set(t,{state:l,transitionend:s,transitioncancel:s,touchstart:g,touchmove:f,touchend:b,touchcancel:b})}function it(t){const e=X.get(t);e&&(X.delete(t),t.addEventListener("transitionend",e.transitionend),t.addEventListener("transitioncancel",e.transitioncancel),t.addEventListener("touchstart",e.touchstart),t.addEventListener("touchmove",e.touchmove),t.addEventListener("touchend",e.touchend),t.addEventListener("touchcancel",e.touchcancel))}const st=r.defineComponent({__name:"index",props:{dragRemove:{type:Boolean,default:!0},removeViewPage:{},removeMoveRatio:{default:.5},momentumReduceRatio:{default:1},resetDelay:{default:120},swipeDuration:{default:60},draggableArea:{},routerViewName:{},viewTag:{type:[Function,String],default:"div"},transition:{type:[Function,Boolean],default:!0},viewClass:{type:[Function,String],default:"fox-root-navigator__item"}},setup(t){const e=t;let n=null,o=null;function i(s){return(s.params&&s.params.animationType)??"slide"}function h(s){return(s.params&&s.params.dragRemove)??e.dragRemove}const p=(s,g,f,b)=>{if(f.opsType===L.OperationType.Append||g){const d=i(f),a=g?"show":"enter";if(a==="show"&&(d==="pop"||o!=="leave"||(n?i(n):"")==="pop"))return;a==="enter"&&(n=f,o="enter");const v=`fox-root-navigator__${d}-${a}-from`,E=`fox-root-navigator__${d}-${a}-active`;s.classList.add(v),s.classList.add(E)}},m=(s,g,f,b)=>{if(f.opsType===L.OperationType.Append||g){const d=i(f),a=g?"show":"enter";if(a==="show"&&(d==="pop"||o!=="leave"||(n?i(n):"")==="pop"))return;const v=`fox-root-navigator__${d}-${a}-from`,E=`fox-root-navigator__${d}-${a}-to`;s.classList.remove(v),s.classList.add(E)}},l=(s,g,f,b)=>{if(f.opsType===L.OperationType.Append||g){const a=i(f),v=g?"show":"enter";if(v==="enter"&&(n=null,o=null),a!=="pop"){const E=`fox-root-navigator__${a}-${v}-active`,w=`fox-root-navigator__${a}-${v}-to`;s.classList.remove(E),s.classList.remove(w)}}if(h(f)===!0&&!g&&f.opsType===L.OperationType.Append){let a=null;e.draggableArea&&(a=function(v,E,w){const c=E-v.offsetLeft,T=w-v.offsetTop;return!(e.draggableArea?.left&&c<e.draggableArea?.left||e.draggableArea?.right&&c>e.draggableArea?.right||e.draggableArea?.top&&T<e.draggableArea?.top||e.draggableArea?.bottom&&T>e.draggableArea?.bottom)}),ot(s,e.removeMoveRatio,e.momentumReduceRatio,e.removeViewPage,"fox-root-navigator__item-moving",e.swipeDuration,e.resetDelay,a)}},_=(s,g,f,b)=>{if(f.opsType===L.OperationType.Append||g){const d=i(f),a=g?"hide":"leave";if(a==="hide"&&(d==="pop"||o!=="enter"||(n?i(n):"")==="pop"))return;a==="leave"&&(n=f,o="leave");const v=`fox-root-navigator__${d}-${a}-from`,E=`fox-root-navigator__${d}-${a}-active`;s.classList.add(v),s.classList.add(E)}},u=(s,g,f,b)=>{if(f.opsType===L.OperationType.Append||g){const d=i(f),a=g?"hide":"leave";if(a==="hide"&&(d==="pop"||o!=="enter"||(n?i(n):"")==="pop"))return;const v=`fox-root-navigator__${d}-${a}-from`,E=`fox-root-navigator__${d}-${a}-to`;s.classList.remove(v),s.classList.add(E)}},y=(s,g,f,b)=>{if(f.opsType===L.OperationType.Append||g){const a=i(f),v=g?"hide":"leave";if(v==="leave"&&(n=null,o=null),a!=="pop"){const E=`fox-root-navigator__${a}-${v}-active`,w=`fox-root-navigator__${a}-${v}-to`;s.classList.remove(E),s.classList.remove(w)}}h(f)&&!g&&it(s)};return(s,g)=>{const f=r.resolveComponent("fox-router-view");return r.openBlock(),r.createBlock(f,{class:"fox-root-navigator","view-class":s.viewClass,"before-enter":p,enter:m,"after-enter":l,"before-leave":_,leave:u,"after-leave":y,multi:!0,name:s.routerViewName,"view-tag":s.viewTag,transition:s.transition},null,8,["view-class","name","view-tag","transition"])}}}),at=Object.freeze(Object.defineProperty({__proto__:null,default:st},Symbol.toStringTag,{value:"Module"})),rt={class:"fox-swiper-navigator"},ct=r.defineComponent({__name:"swiper",props:{width:{},scrollDistance:{},scrollDuration:{},direction:{}},setup(t){const e=t,n=r.computed(()=>{const o={transform:`translate3d(${e.scrollDistance}px, 0, 0)`,width:`${e.width}`};return e.scrollDuration>0&&(o["transition-duration"]=`${e.scrollDuration}ms`),o});return(o,i)=>(r.openBlock(),r.createElementBlock("div",rt,[r.createElementVNode("div",{class:"fox-swiper-navigator__inner",style:r.normalizeStyle(n.value)},[r.renderSlot(o.$slots,"default")],4)]))}});let lt=0;function ut(){return++lt}const dt=15,ft=300,ht=200;function mt(t){t.stopPropagation()}function pt(t,e,n=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*n}function I(t,e=0,n,o=ht){n==="end"?t.style.transition=`transform ${o}ms linear`:t.style.transition="transform 0ms linear",t.style.transform=`translate3d(${e}px, 0, 0)`}class gt{width=0;columnWidth=0;max=0;min=0;el=null;swipeDuration=360;transitionEndTrigger=null;moving=!1;startDistance=0;scrollDistance=0;getStartDistance;openPage;isPageOpened;pageOpened;moveRatio=.5;momentumReduceRatio=1;transitionend=null;touchstart=null;touchmove=null;touchend=null;touchcancel=null;constructor(e,n,o,i,h,p){this.getStartDistance=e,this.openPage=n,this.isPageOpened=o,this.pageOpened=i,this.moveRatio=h,this.momentumReduceRatio=p}open(){const e=this.el,n=B(),o=(i,h,p,m)=>{let l=h+this.startDistance;const _=this.columnWidth*this.moveRatio;if(p==="end"){if(h==0){this.moving=!1;return}Math.abs(h)>_?h>0?l=this.startDistance+this.columnWidth:l=this.startDistance-this.columnWidth:l=this.startDistance;let u=-l;u<0?u=0:u>this.width-this.columnWidth&&(u=this.width-this.columnWidth);const y=Math.floor(u/this.columnWidth);this.isPageOpened(y)||this.openPage(y),l=-y*this.columnWidth,m&&m>0&&(this.transitionEndTrigger=()=>{this.moving=!1,this.pageOpened(y)}),I(i,l,"end",m),this.scrollDistance=l}else{if(Math.abs(h)>_){let y=0;if(h>0?y=Math.abs(this.startDistance+this.columnWidth):y=Math.abs(this.startDistance-this.columnWidth),y>=0&&y<this.width){const s=Math.floor(y/this.columnWidth);this.isPageOpened(s)||this.openPage(s)}}let u=-l;u<this.min?u=this.min:u>this.max&&(u=this.max),I(i,-u,"",0)}};this.transitionend=()=>{e.style.transition="",this.transitionEndTrigger&&(this.transitionEndTrigger(),this.transitionEndTrigger=null)},this.touchstart=i=>{this.moving||(n.start(i),this.startDistance=this.getStartDistance(),this.transitionEndTrigger=null,this.moving=!0)},this.touchmove=i=>{n.move(i),!n.isVertical()&&(mt(i),o(e,n.state.deltaX,"",0))},this.touchend=()=>{if(n.isVertical())return;const i=n.state.deltaX;if(i==0)return;const h=n.state.duration;if(h<ft&&Math.abs(i)>dt){const m=pt(i,h,this.momentumReduceRatio);o(e,m,"end",this.swipeDuration)}else o(e,i,"end",this.swipeDuration)},e.addEventListener("transitionend",this.transitionend),e.addEventListener("touchstart",this.touchstart),e.addEventListener("touchmove",this.touchmove),e.addEventListener("touchend",this.touchend),e.addEventListener("touchcancel",this.touchend)}close(){const e=this.el;this.transitionend&&e.addEventListener("transitionend",this.transitionend),this.touchstart&&e.addEventListener("touchstart",this.touchstart),this.touchmove&&e.addEventListener("touchmove",this.touchmove),this.touchend&&e.addEventListener("touchend",this.touchend),this.touchcancel&&e.addEventListener("touchcancel",this.touchcancel),this.el=null}}function vt(t,e,n,o,i,h){return new gt(t,e,n,o,i,h)}function _t(t){const e=r.unref(t),n=window.getComputedStyle(e,null),o=parseFloat(n.getPropertyValue("padding-left")),i=parseFloat(n.getPropertyValue("padding-right")),h=parseFloat(n.getPropertyValue("padding-top")),p=parseFloat(n.getPropertyValue("padding-bottom"));return{width:e.clientWidth-o-i,height:e.clientHeight-h-p}}const wt=r.defineComponent({__name:"index",props:{activePath:{},routes:{},height:{default:-1},width:{default:-1},draggable:{type:Boolean,default:!0},openViewPage:{},routerViewName:{},moveRatio:{default:.5},momentumReduceRatio:{default:1},direction:{default:"horizontal"},transition:{type:[Function,Boolean],default:!0},swipeDuration:{default:360},scrollDuration:{},customClass:{},customStyle:{}},emits:["update:activePath"],setup(t,{emit:e}){const n=t,o=r.reactive({scrollDistance:0,index:-1,openedIndexList:[],width:n.width,height:n.height}),i=e,h=()=>o.scrollDistance,p=c=>{if(o.openedIndexList.indexOf(c)===-1){o.openedIndexList.push(c);const T=n.routes[c];try{n.openViewPage(T,c)}catch(x){console.error(x)}}},m=c=>o.openedIndexList.indexOf(c)!==-1,l=c=>{o.index=c,o.width>0?o.scrollDistance=-o.index*o.width:o.scrollDistance=0;const T=n.routes[c];i("update:activePath",T.path)};let _=null;n.draggable&&(_=vt(h,p,m,l,n.moveRatio,n.momentumReduceRatio));let u=null;r.onMounted(()=>{const c=d(),T=()=>{const x=_t(c);y(n.activePath,n.routes,x.width,x.height,n.swipeDuration,n.direction)};if(window.ResizeObserver&&(u=new window.ResizeObserver(T),u.observe(c)),T(),_){const x=v();_.el=x,_.open()}}),r.onBeforeUnmount(()=>{u&&(u.disconnect(),u=null),_&&_.close()}),r.watch([()=>n.activePath,()=>n.routes,()=>n.width,()=>n.height,()=>n.swipeDuration,()=>n.direction],([c,T,x,$,M,R])=>{const O=x<=0?o.width:x,D=$<=0?o.height:$;y(c,T,O,D,M,R)});const y=(c,T,x,$,M,R="horizontal")=>{const O=c;if(o.index=T.findIndex(D=>D.path===O),R==="horizontal"){const D=x;if(D>0){o.width=x;const z=D*n.routes.length,W=-D/3,N=D*(T.length-1)+D/3;_&&(_.columnWidth=D,_.width=z,_.min=W,_.max=N),o.index!==-1&&(o.openedIndexList.push(o.index),o.scrollDistance=-D*o.index)}}_&&(_.swipeDuration=M)},s=`fox-swiper-navigator-${ut()}`,g=r.computed(()=>{const c=[s];return n.customClass&&c.push(n.customClass),c}),f=r.computed(()=>{const c={},T=o.width>0?o.width:n.width;T>0&&(c.width=`${T}px`);const x=o.height>0?o.height:n.height;return x>0&&(c.height=`${x}px`),n.customStyle&&Object.assign(c,n.customStyle),c});let b=null;function d(){return b||(b=document.querySelector(`.${s}`),b)}let a=null;function v(){return a||(a=document.querySelector(`.${s}>.fox-swiper-navigator__inner`),a)}const E=r.computed(()=>o.width>0?`${o.width*n.routes.length}px`:"100%"),w=(c,T)=>{const x=n.routes.findIndex($=>{const M=c.path??c.name??"";return $.path==M});return o.width<=0?{}:{style:{left:`${x*o.width}px`,width:`${o.width}px`}}};return(c,T)=>{const x=r.resolveComponent("fox-router-view");return r.openBlock(),r.createBlock(x,{class:r.normalizeClass(g.value),style:r.normalizeStyle(f.value),"view-class":"fox-swiper-navigator__item",tag:ct,"view-tag-props":w,multi:!0,name:c.routerViewName,transition:c.transition,"scroll-distance":o.scrollDistance,"scroll-duration":c.scrollDuration,direction:c.direction,width:E.value},null,8,["class","style","name","transition","scroll-distance","scroll-duration","direction","width"])}}}),Tt=Object.freeze(Object.defineProperty({__proto__:null,default:wt},Symbol.toStringTag,{value:"Module"}));let yt="fox-";const xt=[],Y=Object.assign({"/src/components/card-navigator/index.vue":F,"/src/components/default-navigator/index.vue":j,"/src/components/root-navigator/index.vue":at,"/src/components/swiper-navigator/index.vue":Tt}),V=[];for(const t in Y){let e=/src\/components\/(.*)\/index.vue/.exec(t)[1];xt.indexOf(e)===-1&&V.push({name:e,component:Y[t].default})}const Et={install(t){V.forEach(e=>{t.component(`${yt}${e.name}`,e.component)})}};module.exports=Et;
|
package/dist/index.esm.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { FoxLeaveEnd as rt, OperationType as
|
|
1
|
+
import { defineComponent as A, resolveComponent as X, openBlock as L, createBlock as R, withCtx as V, createVNode as J, Transition as K, resolveDynamicComponent as Q, unref as F, computed as P, createElementBlock as Z, createElementVNode as tt, normalizeStyle as U, renderSlot as et, reactive as nt, onMounted as ot, onBeforeUnmount as it, watch as st, normalizeClass as at } from "vue";
|
|
2
|
+
import { FoxLeaveEnd as rt, OperationType as D } from "@fox-js/fox";
|
|
3
3
|
/*!
|
|
4
|
-
* @fox-js/navigation v4.0.1-
|
|
4
|
+
* @fox-js/navigation v4.0.1-15 Sat Jun 15 2024 16:18:22 GMT+0800 (中国标准时间)
|
|
5
5
|
*/
|
|
6
|
-
const ct = /* @__PURE__ */
|
|
6
|
+
const ct = /* @__PURE__ */ A({
|
|
7
7
|
__name: "index",
|
|
8
8
|
props: {
|
|
9
9
|
routerViewName: {},
|
|
@@ -11,8 +11,8 @@ const ct = /* @__PURE__ */ P({
|
|
|
11
11
|
},
|
|
12
12
|
setup(t) {
|
|
13
13
|
return (e, n) => {
|
|
14
|
-
const o =
|
|
15
|
-
return
|
|
14
|
+
const o = X("fox-router-view");
|
|
15
|
+
return L(), R(o, {
|
|
16
16
|
class: "fox-card-navigator",
|
|
17
17
|
"view-class": "fox-card-navigator__item",
|
|
18
18
|
"view-active-class": "fox-card-navigator__item-active",
|
|
@@ -27,7 +27,7 @@ const ct = /* @__PURE__ */ P({
|
|
|
27
27
|
}), lt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
28
28
|
__proto__: null,
|
|
29
29
|
default: ct
|
|
30
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
30
|
+
}, Symbol.toStringTag, { value: "Module" })), dt = /* @__PURE__ */ A({
|
|
31
31
|
__name: "index",
|
|
32
32
|
props: {
|
|
33
33
|
routerViewName: {},
|
|
@@ -35,16 +35,16 @@ const ct = /* @__PURE__ */ P({
|
|
|
35
35
|
},
|
|
36
36
|
setup(t) {
|
|
37
37
|
return (e, n) => {
|
|
38
|
-
const o =
|
|
39
|
-
return
|
|
38
|
+
const o = X("fox-router-view");
|
|
39
|
+
return L(), R(o, {
|
|
40
40
|
transition: !1,
|
|
41
41
|
multi: !1,
|
|
42
42
|
name: e.routerViewName
|
|
43
43
|
}, {
|
|
44
|
-
default:
|
|
44
|
+
default: V(({ Component: i }) => [
|
|
45
45
|
J(K, { name: "fox-default-navigator__trans" }, {
|
|
46
|
-
default:
|
|
47
|
-
(
|
|
46
|
+
default: V(() => [
|
|
47
|
+
(L(), R(Q(i)))
|
|
48
48
|
]),
|
|
49
49
|
_: 2
|
|
50
50
|
}, 1024)
|
|
@@ -53,9 +53,9 @@ const ct = /* @__PURE__ */ P({
|
|
|
53
53
|
}, 8, ["name"]);
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
|
-
}),
|
|
56
|
+
}), ut = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
57
57
|
__proto__: null,
|
|
58
|
-
default:
|
|
58
|
+
default: dt
|
|
59
59
|
}, Symbol.toStringTag, { value: "Module" })), W = 10;
|
|
60
60
|
function ft(t, e) {
|
|
61
61
|
return t > e && t > W ? "horizontal" : e > t && e > W ? "vertical" : "";
|
|
@@ -77,20 +77,20 @@ function j() {
|
|
|
77
77
|
t.deltaX = 0, t.deltaY = 0, t.offsetX = 0, t.offsetY = 0, t.direction = "", t.startTime = 0;
|
|
78
78
|
};
|
|
79
79
|
return {
|
|
80
|
-
move: (
|
|
81
|
-
if (
|
|
82
|
-
const
|
|
83
|
-
t.deltaX = s.clientX - t.startX, t.deltaY = s.clientY - t.startY, t.moveX = s.clientX, t.moveY = s.clientY;
|
|
84
|
-
} else
|
|
80
|
+
move: (m) => {
|
|
81
|
+
if (m.touches) {
|
|
82
|
+
const h = m.touches[0];
|
|
85
83
|
t.deltaX = h.clientX - t.startX, t.deltaY = h.clientY - t.startY, t.moveX = h.clientX, t.moveY = h.clientY;
|
|
84
|
+
} else
|
|
85
|
+
t.deltaX = m.clientX - t.startX, t.deltaY = m.clientY - t.startY, t.moveX = m.clientX, t.moveY = m.clientY;
|
|
86
86
|
t.offsetX = Math.abs(t.deltaX), t.offsetY = Math.abs(t.deltaY), t.duration = Date.now() - t.startTime, t.direction || (t.direction = ft(t.offsetX, t.offsetY));
|
|
87
87
|
},
|
|
88
|
-
start: (
|
|
89
|
-
if (o(),
|
|
90
|
-
const
|
|
91
|
-
t.startX = s.clientX, t.startY = s.clientY;
|
|
92
|
-
} else
|
|
88
|
+
start: (m) => {
|
|
89
|
+
if (o(), m.touches) {
|
|
90
|
+
const h = m.touches[0];
|
|
93
91
|
t.startX = h.clientX, t.startY = h.clientY;
|
|
92
|
+
} else
|
|
93
|
+
t.startX = m.clientX, t.startY = m.clientY;
|
|
94
94
|
t.startTime = Date.now();
|
|
95
95
|
},
|
|
96
96
|
reset: o,
|
|
@@ -130,11 +130,11 @@ const mt = (t) => {
|
|
|
130
130
|
detail: void 0
|
|
131
131
|
};
|
|
132
132
|
const o = document.createEvent("Events");
|
|
133
|
-
let i = !0,
|
|
134
|
-
for (let
|
|
135
|
-
|
|
136
|
-
o.initEvent(t, i,
|
|
137
|
-
},
|
|
133
|
+
let i = !0, f = !0;
|
|
134
|
+
for (let h in e)
|
|
135
|
+
h === "bubbles" ? i = !!e[h] : h === "cancelable" ? f = !!e[h] : o[h] = e[h];
|
|
136
|
+
o.initEvent(t, i, f), (n ?? document).dispatchEvent(o);
|
|
137
|
+
}, gt = 15, vt = 300, _t = 200;
|
|
138
138
|
function wt(t) {
|
|
139
139
|
t.stopPropagation();
|
|
140
140
|
}
|
|
@@ -157,63 +157,68 @@ function I(t) {
|
|
|
157
157
|
}
|
|
158
158
|
return e;
|
|
159
159
|
}
|
|
160
|
-
const
|
|
161
|
-
function yt(t, e, n, o, i,
|
|
162
|
-
const
|
|
160
|
+
const Y = /* @__PURE__ */ new WeakMap();
|
|
161
|
+
function yt(t, e, n, o, i, f = 600, m = 60, h = null) {
|
|
162
|
+
const c = {
|
|
163
163
|
active: !0,
|
|
164
164
|
startDistance: 0,
|
|
165
165
|
scrollDistance: 0,
|
|
166
166
|
scrollTime: 0,
|
|
167
167
|
moving: !1,
|
|
168
|
+
dragging: !1,
|
|
168
169
|
transitionEndTrigger: null
|
|
169
|
-
},
|
|
170
|
-
let
|
|
171
|
-
if (
|
|
172
|
-
const
|
|
173
|
-
let
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
},
|
|
178
|
-
},
|
|
170
|
+
}, v = t.previousSibling, l = j(), T = (d, a, g, y) => {
|
|
171
|
+
let _ = a + c.startDistance;
|
|
172
|
+
if (g === "end") {
|
|
173
|
+
const r = mt(d);
|
|
174
|
+
let w = r.width * e;
|
|
175
|
+
_ < w ? _ = 0 : _ = r.width, c.transitionEndTrigger = () => {
|
|
176
|
+
c.moving = !1, i && d.classList.remove(i), setTimeout(() => {
|
|
177
|
+
v && z(v), _ == 0 ? z(d) : pt(rt, {}, d), c.moving = !1;
|
|
178
|
+
}, m);
|
|
179
|
+
}, v && C(v, 0, "", 0), _ > 0 && typeof o == "function" && o(), C(d, _, "end", y);
|
|
179
180
|
} else
|
|
180
|
-
|
|
181
|
-
},
|
|
182
|
-
|
|
183
|
-
},
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
s.moving = !0, d.move(g), !(d.isVertical() || I(t) === 0 && d.state.deltaX < 0) && (wt(g), v(t, d.state.deltaX, "", 0));
|
|
187
|
-
}, l = () => {
|
|
188
|
-
if (d.isVertical() || I(t) === 0 && d.state.deltaX < 0)
|
|
181
|
+
_ < 0 && (_ = 0), C(d, _, "", 0);
|
|
182
|
+
}, s = () => {
|
|
183
|
+
c.transitionEndTrigger && (c.transitionEndTrigger(), c.transitionEndTrigger = null);
|
|
184
|
+
}, p = (d) => {
|
|
185
|
+
if (l.start(d), c.draging = h ? h(t, l.state.startX, l.state.startY) : !0, !c.draging) {
|
|
186
|
+
l.reset();
|
|
189
187
|
return;
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
188
|
+
}
|
|
189
|
+
c.scrollDistance = 0, c.moving && (c.scrollDistance = I(t)), i && t.classList.add(i), c.transitionEndTrigger = null, c.moving = !0;
|
|
190
|
+
}, u = (d) => {
|
|
191
|
+
!c.draging || (c.moving = !0, l.move(d), l.isVertical()) || I(t) === 0 && l.state.deltaX < 0 || (wt(d), T(t, l.state.deltaX, "", 0));
|
|
192
|
+
}, E = () => {
|
|
193
|
+
if (!c.draging || (c.draging = !1, l.isVertical()) || I(t) === 0 && l.state.deltaX < 0)
|
|
194
|
+
return;
|
|
195
|
+
const a = l.state.deltaX;
|
|
196
|
+
if (a === 0) {
|
|
197
|
+
i && t.classList.remove(i), c.moving = !1;
|
|
193
198
|
return;
|
|
194
199
|
}
|
|
195
|
-
const
|
|
196
|
-
if (
|
|
197
|
-
const
|
|
198
|
-
|
|
200
|
+
const g = l.state.duration;
|
|
201
|
+
if (g < vt && Math.abs(a) > gt) {
|
|
202
|
+
const _ = Tt(a, g, n);
|
|
203
|
+
T(t, _, "end", f);
|
|
199
204
|
} else
|
|
200
|
-
|
|
205
|
+
T(t, a, "end", f);
|
|
201
206
|
};
|
|
202
|
-
t.addEventListener("transitionend",
|
|
203
|
-
state:
|
|
204
|
-
transitionend:
|
|
205
|
-
transitioncancel:
|
|
206
|
-
touchstart:
|
|
207
|
-
touchmove:
|
|
208
|
-
touchend:
|
|
209
|
-
touchcancel:
|
|
207
|
+
t.addEventListener("transitionend", s), t.addEventListener("transitioncancel", s), t.addEventListener("touchstart", p), t.addEventListener("touchmove", u), t.addEventListener("touchend", E), t.addEventListener("touchcancel", E), Y.set(t, {
|
|
208
|
+
state: c,
|
|
209
|
+
transitionend: s,
|
|
210
|
+
transitioncancel: s,
|
|
211
|
+
touchstart: p,
|
|
212
|
+
touchmove: u,
|
|
213
|
+
touchend: E,
|
|
214
|
+
touchcancel: E
|
|
210
215
|
});
|
|
211
216
|
}
|
|
212
217
|
function Et(t) {
|
|
213
|
-
const e =
|
|
214
|
-
e && (
|
|
218
|
+
const e = Y.get(t);
|
|
219
|
+
e && (Y.delete(t), t.addEventListener("transitionend", e.transitionend), t.addEventListener("transitioncancel", e.transitioncancel), t.addEventListener("touchstart", e.touchstart), t.addEventListener("touchmove", e.touchmove), t.addEventListener("touchend", e.touchend), t.addEventListener("touchcancel", e.touchcancel));
|
|
215
220
|
}
|
|
216
|
-
const
|
|
221
|
+
const bt = /* @__PURE__ */ A({
|
|
217
222
|
__name: "index",
|
|
218
223
|
props: {
|
|
219
224
|
dragRemove: { type: Boolean, default: !0 },
|
|
@@ -222,6 +227,7 @@ const Dt = /* @__PURE__ */ P({
|
|
|
222
227
|
momentumReduceRatio: { default: 1 },
|
|
223
228
|
resetDelay: { default: 120 },
|
|
224
229
|
swipeDuration: { default: 60 },
|
|
230
|
+
draggableArea: {},
|
|
225
231
|
routerViewName: {},
|
|
226
232
|
viewTag: { type: [Function, String], default: "div" },
|
|
227
233
|
transition: { type: [Function, Boolean], default: !0 },
|
|
@@ -230,95 +236,102 @@ const Dt = /* @__PURE__ */ P({
|
|
|
230
236
|
setup(t) {
|
|
231
237
|
const e = t;
|
|
232
238
|
let n = null, o = null;
|
|
233
|
-
function i(
|
|
234
|
-
return (
|
|
239
|
+
function i(s) {
|
|
240
|
+
return (s.params && s.params.animationType) ?? "slide";
|
|
235
241
|
}
|
|
236
|
-
function
|
|
237
|
-
return (
|
|
242
|
+
function f(s) {
|
|
243
|
+
return (s.params && s.params.dragRemove) ?? e.dragRemove;
|
|
238
244
|
}
|
|
239
|
-
const
|
|
240
|
-
if (
|
|
241
|
-
const
|
|
242
|
-
if (
|
|
245
|
+
const m = (s, p, u, E) => {
|
|
246
|
+
if (u.opsType === D.Append || p) {
|
|
247
|
+
const d = i(u), a = p ? "show" : "enter";
|
|
248
|
+
if (a === "show" && (d === "pop" || o !== "leave" || (n ? i(n) : "") === "pop"))
|
|
243
249
|
return;
|
|
244
|
-
|
|
245
|
-
const
|
|
246
|
-
|
|
250
|
+
a === "enter" && (n = u, o = "enter");
|
|
251
|
+
const g = `fox-root-navigator__${d}-${a}-from`, y = `fox-root-navigator__${d}-${a}-active`;
|
|
252
|
+
s.classList.add(g), s.classList.add(y);
|
|
247
253
|
}
|
|
248
|
-
},
|
|
249
|
-
if (
|
|
250
|
-
const
|
|
251
|
-
if (
|
|
254
|
+
}, h = (s, p, u, E) => {
|
|
255
|
+
if (u.opsType === D.Append || p) {
|
|
256
|
+
const d = i(u), a = p ? "show" : "enter";
|
|
257
|
+
if (a === "show" && (d === "pop" || o !== "leave" || (n ? i(n) : "") === "pop"))
|
|
252
258
|
return;
|
|
253
|
-
const
|
|
254
|
-
|
|
259
|
+
const g = `fox-root-navigator__${d}-${a}-from`, y = `fox-root-navigator__${d}-${a}-to`;
|
|
260
|
+
s.classList.remove(g), s.classList.add(y);
|
|
255
261
|
}
|
|
256
|
-
},
|
|
257
|
-
if (
|
|
258
|
-
const
|
|
259
|
-
if (
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
+
}, c = (s, p, u, E) => {
|
|
263
|
+
if (u.opsType === D.Append || p) {
|
|
264
|
+
const a = i(u), g = p ? "show" : "enter";
|
|
265
|
+
if (g === "enter" && (n = null, o = null), a !== "pop") {
|
|
266
|
+
const y = `fox-root-navigator__${a}-${g}-active`, _ = `fox-root-navigator__${a}-${g}-to`;
|
|
267
|
+
s.classList.remove(y), s.classList.remove(_);
|
|
262
268
|
}
|
|
263
269
|
}
|
|
264
|
-
u
|
|
265
|
-
a
|
|
266
|
-
e.
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
270
|
+
if (f(u) === !0 && !p && u.opsType === D.Append) {
|
|
271
|
+
let a = null;
|
|
272
|
+
e.draggableArea && (a = function(g, y, _) {
|
|
273
|
+
const r = y - g.offsetLeft, w = _ - g.offsetTop;
|
|
274
|
+
return !(e.draggableArea?.left && r < e.draggableArea?.left || e.draggableArea?.right && r > e.draggableArea?.right || e.draggableArea?.top && w < e.draggableArea?.top || e.draggableArea?.bottom && w > e.draggableArea?.bottom);
|
|
275
|
+
}), yt(
|
|
276
|
+
s,
|
|
277
|
+
e.removeMoveRatio,
|
|
278
|
+
e.momentumReduceRatio,
|
|
279
|
+
e.removeViewPage,
|
|
280
|
+
"fox-root-navigator__item-moving",
|
|
281
|
+
e.swipeDuration,
|
|
282
|
+
e.resetDelay,
|
|
283
|
+
a
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
}, v = (s, p, u, E) => {
|
|
287
|
+
if (u.opsType === D.Append || p) {
|
|
288
|
+
const d = i(u), a = p ? "hide" : "leave";
|
|
289
|
+
if (a === "hide" && (d === "pop" || o !== "enter" || (n ? i(n) : "") === "pop"))
|
|
277
290
|
return;
|
|
278
|
-
|
|
279
|
-
const
|
|
280
|
-
|
|
291
|
+
a === "leave" && (n = u, o = "leave");
|
|
292
|
+
const g = `fox-root-navigator__${d}-${a}-from`, y = `fox-root-navigator__${d}-${a}-active`;
|
|
293
|
+
s.classList.add(g), s.classList.add(y);
|
|
281
294
|
}
|
|
282
|
-
},
|
|
283
|
-
if (
|
|
284
|
-
const
|
|
285
|
-
if (
|
|
295
|
+
}, l = (s, p, u, E) => {
|
|
296
|
+
if (u.opsType === D.Append || p) {
|
|
297
|
+
const d = i(u), a = p ? "hide" : "leave";
|
|
298
|
+
if (a === "hide" && (d === "pop" || o !== "enter" || (n ? i(n) : "") === "pop"))
|
|
286
299
|
return;
|
|
287
|
-
const
|
|
288
|
-
|
|
300
|
+
const g = `fox-root-navigator__${d}-${a}-from`, y = `fox-root-navigator__${d}-${a}-to`;
|
|
301
|
+
s.classList.remove(g), s.classList.add(y);
|
|
289
302
|
}
|
|
290
|
-
},
|
|
291
|
-
if (
|
|
292
|
-
const
|
|
293
|
-
if (
|
|
294
|
-
const
|
|
295
|
-
|
|
303
|
+
}, T = (s, p, u, E) => {
|
|
304
|
+
if (u.opsType === D.Append || p) {
|
|
305
|
+
const a = i(u), g = p ? "hide" : "leave";
|
|
306
|
+
if (g === "leave" && (n = null, o = null), a !== "pop") {
|
|
307
|
+
const y = `fox-root-navigator__${a}-${g}-active`, _ = `fox-root-navigator__${a}-${g}-to`;
|
|
308
|
+
s.classList.remove(y), s.classList.remove(_);
|
|
296
309
|
}
|
|
297
310
|
}
|
|
298
|
-
u
|
|
311
|
+
f(u) && !p && Et(s);
|
|
299
312
|
};
|
|
300
|
-
return (
|
|
301
|
-
const
|
|
302
|
-
return
|
|
313
|
+
return (s, p) => {
|
|
314
|
+
const u = X("fox-router-view");
|
|
315
|
+
return L(), R(u, {
|
|
303
316
|
class: "fox-root-navigator",
|
|
304
|
-
"view-class":
|
|
305
|
-
"before-enter":
|
|
306
|
-
enter:
|
|
307
|
-
"after-enter":
|
|
308
|
-
"before-leave":
|
|
309
|
-
leave:
|
|
310
|
-
"after-leave":
|
|
317
|
+
"view-class": s.viewClass,
|
|
318
|
+
"before-enter": m,
|
|
319
|
+
enter: h,
|
|
320
|
+
"after-enter": c,
|
|
321
|
+
"before-leave": v,
|
|
322
|
+
leave: l,
|
|
323
|
+
"after-leave": T,
|
|
311
324
|
multi: !0,
|
|
312
|
-
name:
|
|
313
|
-
"view-tag":
|
|
314
|
-
transition:
|
|
325
|
+
name: s.routerViewName,
|
|
326
|
+
"view-tag": s.viewTag,
|
|
327
|
+
transition: s.transition
|
|
315
328
|
}, null, 8, ["view-class", "name", "view-tag", "transition"]);
|
|
316
329
|
};
|
|
317
330
|
}
|
|
318
|
-
}),
|
|
331
|
+
}), Dt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
319
332
|
__proto__: null,
|
|
320
|
-
default:
|
|
321
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
333
|
+
default: bt
|
|
334
|
+
}, Symbol.toStringTag, { value: "Module" })), Lt = { class: "fox-swiper-navigator" }, $t = /* @__PURE__ */ A({
|
|
322
335
|
__name: "swiper",
|
|
323
336
|
props: {
|
|
324
337
|
width: {},
|
|
@@ -327,14 +340,14 @@ const Dt = /* @__PURE__ */ P({
|
|
|
327
340
|
direction: {}
|
|
328
341
|
},
|
|
329
342
|
setup(t) {
|
|
330
|
-
const e = t, n =
|
|
343
|
+
const e = t, n = P(() => {
|
|
331
344
|
const o = {
|
|
332
345
|
transform: `translate3d(${e.scrollDistance}px, 0, 0)`,
|
|
333
346
|
width: `${e.width}`
|
|
334
347
|
};
|
|
335
348
|
return e.scrollDuration > 0 && (o["transition-duration"] = `${e.scrollDuration}ms`), o;
|
|
336
349
|
});
|
|
337
|
-
return (o, i) => (
|
|
350
|
+
return (o, i) => (L(), Z("div", Lt, [
|
|
338
351
|
tt("div", {
|
|
339
352
|
class: "fox-swiper-navigator__inner",
|
|
340
353
|
style: U(n.value)
|
|
@@ -348,14 +361,14 @@ let Mt = 0;
|
|
|
348
361
|
function Rt() {
|
|
349
362
|
return ++Mt;
|
|
350
363
|
}
|
|
351
|
-
const
|
|
352
|
-
function
|
|
364
|
+
const At = 15, Pt = 300, Xt = 200;
|
|
365
|
+
function Ot(t) {
|
|
353
366
|
t.stopPropagation();
|
|
354
367
|
}
|
|
355
|
-
function
|
|
368
|
+
function St(t, e, n = 1) {
|
|
356
369
|
return t = Math.abs(t / e) / 3e-3 * (t < 0 ? -1 : 1), t * n;
|
|
357
370
|
}
|
|
358
|
-
function N(t, e = 0, n, o =
|
|
371
|
+
function N(t, e = 0, n, o = Xt) {
|
|
359
372
|
n === "end" ? t.style.transition = `transform ${o}ms linear` : t.style.transition = "transform 0ms linear", t.style.transform = `translate3d(${e}px, 0, 0)`;
|
|
360
373
|
}
|
|
361
374
|
class Ct {
|
|
@@ -453,38 +466,38 @@ class Ct {
|
|
|
453
466
|
* @param momentumReduceRatio
|
|
454
467
|
*
|
|
455
468
|
*/
|
|
456
|
-
constructor(e, n, o, i,
|
|
457
|
-
this.getStartDistance = e, this.openPage = n, this.isPageOpened = o, this.pageOpened = i, this.moveRatio =
|
|
469
|
+
constructor(e, n, o, i, f, m) {
|
|
470
|
+
this.getStartDistance = e, this.openPage = n, this.isPageOpened = o, this.pageOpened = i, this.moveRatio = f, this.momentumReduceRatio = m;
|
|
458
471
|
}
|
|
459
472
|
/**
|
|
460
473
|
* 打开drag支持
|
|
461
474
|
*/
|
|
462
475
|
open() {
|
|
463
|
-
const e = this.el, n = j(), o = (i,
|
|
464
|
-
let
|
|
465
|
-
const
|
|
466
|
-
if (
|
|
467
|
-
if (
|
|
476
|
+
const e = this.el, n = j(), o = (i, f, m, h) => {
|
|
477
|
+
let c = f + this.startDistance;
|
|
478
|
+
const v = this.columnWidth * this.moveRatio;
|
|
479
|
+
if (m === "end") {
|
|
480
|
+
if (f == 0) {
|
|
468
481
|
this.moving = !1;
|
|
469
482
|
return;
|
|
470
483
|
}
|
|
471
|
-
Math.abs(
|
|
472
|
-
let
|
|
473
|
-
|
|
474
|
-
const
|
|
475
|
-
this.isPageOpened(
|
|
476
|
-
this.moving = !1, this.pageOpened(
|
|
477
|
-
}), N(i,
|
|
484
|
+
Math.abs(f) > v ? f > 0 ? c = this.startDistance + this.columnWidth : c = this.startDistance - this.columnWidth : c = this.startDistance;
|
|
485
|
+
let l = -c;
|
|
486
|
+
l < 0 ? l = 0 : l > this.width - this.columnWidth && (l = this.width - this.columnWidth);
|
|
487
|
+
const T = Math.floor(l / this.columnWidth);
|
|
488
|
+
this.isPageOpened(T) || this.openPage(T), c = -T * this.columnWidth, h && h > 0 && (this.transitionEndTrigger = () => {
|
|
489
|
+
this.moving = !1, this.pageOpened(T);
|
|
490
|
+
}), N(i, c, "end", h), this.scrollDistance = c;
|
|
478
491
|
} else {
|
|
479
|
-
if (Math.abs(
|
|
480
|
-
let
|
|
481
|
-
if (
|
|
482
|
-
const
|
|
483
|
-
this.isPageOpened(
|
|
492
|
+
if (Math.abs(f) > v) {
|
|
493
|
+
let T = 0;
|
|
494
|
+
if (f > 0 ? T = Math.abs(this.startDistance + this.columnWidth) : T = Math.abs(this.startDistance - this.columnWidth), T >= 0 && T < this.width) {
|
|
495
|
+
const s = Math.floor(T / this.columnWidth);
|
|
496
|
+
this.isPageOpened(s) || this.openPage(s);
|
|
484
497
|
}
|
|
485
498
|
}
|
|
486
|
-
let
|
|
487
|
-
|
|
499
|
+
let l = -c;
|
|
500
|
+
l < this.min ? l = this.min : l > this.max && (l = this.max), N(i, -l, "", 0);
|
|
488
501
|
}
|
|
489
502
|
};
|
|
490
503
|
this.transitionend = () => {
|
|
@@ -492,17 +505,17 @@ class Ct {
|
|
|
492
505
|
}, this.touchstart = (i) => {
|
|
493
506
|
this.moving || (n.start(i), this.startDistance = this.getStartDistance(), this.transitionEndTrigger = null, this.moving = !0);
|
|
494
507
|
}, this.touchmove = (i) => {
|
|
495
|
-
n.move(i), !n.isVertical() && (
|
|
508
|
+
n.move(i), !n.isVertical() && (Ot(i), o(e, n.state.deltaX, "", 0));
|
|
496
509
|
}, this.touchend = () => {
|
|
497
510
|
if (n.isVertical())
|
|
498
511
|
return;
|
|
499
512
|
const i = n.state.deltaX;
|
|
500
513
|
if (i == 0)
|
|
501
514
|
return;
|
|
502
|
-
const
|
|
503
|
-
if (
|
|
504
|
-
const
|
|
505
|
-
o(e,
|
|
515
|
+
const f = n.state.duration;
|
|
516
|
+
if (f < Pt && Math.abs(i) > At) {
|
|
517
|
+
const h = St(i, f, this.momentumReduceRatio);
|
|
518
|
+
o(e, h, "end", this.swipeDuration);
|
|
506
519
|
} else
|
|
507
520
|
o(e, i, "end", this.swipeDuration);
|
|
508
521
|
}, e.addEventListener("transitionend", this.transitionend), e.addEventListener("touchstart", this.touchstart), e.addEventListener("touchmove", this.touchmove), e.addEventListener("touchend", this.touchend), e.addEventListener("touchcancel", this.touchend);
|
|
@@ -515,17 +528,17 @@ class Ct {
|
|
|
515
528
|
this.transitionend && e.addEventListener("transitionend", this.transitionend), this.touchstart && e.addEventListener("touchstart", this.touchstart), this.touchmove && e.addEventListener("touchmove", this.touchmove), this.touchend && e.addEventListener("touchend", this.touchend), this.touchcancel && e.addEventListener("touchcancel", this.touchcancel), this.el = null;
|
|
516
529
|
}
|
|
517
530
|
}
|
|
518
|
-
function It(t, e, n, o, i,
|
|
519
|
-
return new Ct(t, e, n, o, i,
|
|
531
|
+
function It(t, e, n, o, i, f) {
|
|
532
|
+
return new Ct(t, e, n, o, i, f);
|
|
520
533
|
}
|
|
521
|
-
function
|
|
522
|
-
const e = F(t), n = window.getComputedStyle(e, null), o = parseFloat(n.getPropertyValue("padding-left")), i = parseFloat(n.getPropertyValue("padding-right")),
|
|
534
|
+
function Yt(t) {
|
|
535
|
+
const e = F(t), n = window.getComputedStyle(e, null), o = parseFloat(n.getPropertyValue("padding-left")), i = parseFloat(n.getPropertyValue("padding-right")), f = parseFloat(n.getPropertyValue("padding-top")), m = parseFloat(n.getPropertyValue("padding-bottom"));
|
|
523
536
|
return {
|
|
524
537
|
width: e.clientWidth - o - i,
|
|
525
|
-
height: e.clientHeight -
|
|
538
|
+
height: e.clientHeight - f - m
|
|
526
539
|
};
|
|
527
540
|
}
|
|
528
|
-
const
|
|
541
|
+
const Vt = /* @__PURE__ */ A({
|
|
529
542
|
__name: "index",
|
|
530
543
|
props: {
|
|
531
544
|
activePath: {},
|
|
@@ -552,42 +565,42 @@ const Yt = /* @__PURE__ */ P({
|
|
|
552
565
|
openedIndexList: [],
|
|
553
566
|
width: n.width,
|
|
554
567
|
height: n.height
|
|
555
|
-
}), i = e,
|
|
556
|
-
if (o.openedIndexList.indexOf(
|
|
557
|
-
o.openedIndexList.push(
|
|
558
|
-
const
|
|
568
|
+
}), i = e, f = () => o.scrollDistance, m = (r) => {
|
|
569
|
+
if (o.openedIndexList.indexOf(r) === -1) {
|
|
570
|
+
o.openedIndexList.push(r);
|
|
571
|
+
const w = n.routes[r];
|
|
559
572
|
try {
|
|
560
|
-
n.openViewPage(
|
|
561
|
-
} catch (
|
|
562
|
-
console.error(
|
|
573
|
+
n.openViewPage(w, r);
|
|
574
|
+
} catch (x) {
|
|
575
|
+
console.error(x);
|
|
563
576
|
}
|
|
564
577
|
}
|
|
565
|
-
},
|
|
566
|
-
o.index =
|
|
567
|
-
const
|
|
568
|
-
i("update:activePath",
|
|
578
|
+
}, h = (r) => o.openedIndexList.indexOf(r) !== -1, c = (r) => {
|
|
579
|
+
o.index = r, o.width > 0 ? o.scrollDistance = -o.index * o.width : o.scrollDistance = 0;
|
|
580
|
+
const w = n.routes[r];
|
|
581
|
+
i("update:activePath", w.path);
|
|
569
582
|
};
|
|
570
|
-
let
|
|
571
|
-
n.draggable && (
|
|
572
|
-
|
|
583
|
+
let v = null;
|
|
584
|
+
n.draggable && (v = It(
|
|
585
|
+
f,
|
|
586
|
+
m,
|
|
573
587
|
h,
|
|
574
|
-
|
|
575
|
-
x,
|
|
588
|
+
c,
|
|
576
589
|
n.moveRatio,
|
|
577
590
|
n.momentumReduceRatio
|
|
578
591
|
));
|
|
579
|
-
let
|
|
592
|
+
let l = null;
|
|
580
593
|
ot(() => {
|
|
581
|
-
const
|
|
582
|
-
const
|
|
583
|
-
|
|
594
|
+
const r = d(), w = () => {
|
|
595
|
+
const x = Yt(r);
|
|
596
|
+
T(n.activePath, n.routes, x.width, x.height, n.swipeDuration, n.direction);
|
|
584
597
|
};
|
|
585
|
-
if (window.ResizeObserver && (
|
|
586
|
-
const
|
|
587
|
-
|
|
598
|
+
if (window.ResizeObserver && (l = new window.ResizeObserver(w), l.observe(r)), w(), v) {
|
|
599
|
+
const x = g();
|
|
600
|
+
v.el = x, v.open();
|
|
588
601
|
}
|
|
589
602
|
}), it(() => {
|
|
590
|
-
|
|
603
|
+
l && (l.disconnect(), l = null), v && v.close();
|
|
591
604
|
}), st(
|
|
592
605
|
[
|
|
593
606
|
() => n.activePath,
|
|
@@ -597,75 +610,75 @@ const Yt = /* @__PURE__ */ P({
|
|
|
597
610
|
() => n.swipeDuration,
|
|
598
611
|
() => n.direction
|
|
599
612
|
],
|
|
600
|
-
([
|
|
601
|
-
const
|
|
602
|
-
|
|
613
|
+
([r, w, x, $, M, O]) => {
|
|
614
|
+
const S = x <= 0 ? o.width : x, b = $ <= 0 ? o.height : $;
|
|
615
|
+
T(r, w, S, b, M, O);
|
|
603
616
|
}
|
|
604
617
|
);
|
|
605
|
-
const
|
|
606
|
-
const
|
|
607
|
-
if (o.index =
|
|
608
|
-
const
|
|
609
|
-
if (
|
|
610
|
-
o.width =
|
|
611
|
-
const q =
|
|
612
|
-
|
|
618
|
+
const T = (r, w, x, $, M, O = "horizontal") => {
|
|
619
|
+
const S = r;
|
|
620
|
+
if (o.index = w.findIndex((b) => b.path === S), O === "horizontal") {
|
|
621
|
+
const b = x;
|
|
622
|
+
if (b > 0) {
|
|
623
|
+
o.width = x;
|
|
624
|
+
const q = b * n.routes.length, H = -b / 3, G = b * (w.length - 1) + b / 3;
|
|
625
|
+
v && (v.columnWidth = b, v.width = q, v.min = H, v.max = G), o.index !== -1 && (o.openedIndexList.push(o.index), o.scrollDistance = -b * o.index);
|
|
613
626
|
}
|
|
614
627
|
}
|
|
615
|
-
|
|
616
|
-
},
|
|
617
|
-
const
|
|
618
|
-
return n.customClass &&
|
|
619
|
-
}),
|
|
620
|
-
const
|
|
621
|
-
|
|
622
|
-
const
|
|
623
|
-
return
|
|
628
|
+
v && (v.swipeDuration = M);
|
|
629
|
+
}, s = `fox-swiper-navigator-${Rt()}`, p = P(() => {
|
|
630
|
+
const r = [s];
|
|
631
|
+
return n.customClass && r.push(n.customClass), r;
|
|
632
|
+
}), u = P(() => {
|
|
633
|
+
const r = {}, w = o.width > 0 ? o.width : n.width;
|
|
634
|
+
w > 0 && (r.width = `${w}px`);
|
|
635
|
+
const x = o.height > 0 ? o.height : n.height;
|
|
636
|
+
return x > 0 && (r.height = `${x}px`), n.customStyle && Object.assign(r, n.customStyle), r;
|
|
624
637
|
});
|
|
625
|
-
let
|
|
626
|
-
function
|
|
627
|
-
return
|
|
638
|
+
let E = null;
|
|
639
|
+
function d() {
|
|
640
|
+
return E || (E = document.querySelector(`.${s}`), E);
|
|
628
641
|
}
|
|
629
|
-
let
|
|
630
|
-
function
|
|
631
|
-
return
|
|
642
|
+
let a = null;
|
|
643
|
+
function g() {
|
|
644
|
+
return a || (a = document.querySelector(`.${s}>.fox-swiper-navigator__inner`), a);
|
|
632
645
|
}
|
|
633
|
-
const
|
|
634
|
-
const
|
|
635
|
-
const M =
|
|
646
|
+
const y = P(() => o.width > 0 ? `${o.width * n.routes.length}px` : "100%"), _ = (r, w) => {
|
|
647
|
+
const x = n.routes.findIndex(($) => {
|
|
648
|
+
const M = r.path ?? r.name ?? "";
|
|
636
649
|
return $.path == M;
|
|
637
650
|
});
|
|
638
651
|
return o.width <= 0 ? {} : {
|
|
639
652
|
style: {
|
|
640
|
-
left: `${
|
|
653
|
+
left: `${x * o.width}px`,
|
|
641
654
|
width: `${o.width}px`
|
|
642
655
|
}
|
|
643
656
|
};
|
|
644
657
|
};
|
|
645
|
-
return (
|
|
646
|
-
const
|
|
647
|
-
return
|
|
648
|
-
class: at(
|
|
649
|
-
style: U(
|
|
658
|
+
return (r, w) => {
|
|
659
|
+
const x = X("fox-router-view");
|
|
660
|
+
return L(), R(x, {
|
|
661
|
+
class: at(p.value),
|
|
662
|
+
style: U(u.value),
|
|
650
663
|
"view-class": "fox-swiper-navigator__item",
|
|
651
664
|
tag: $t,
|
|
652
|
-
"view-tag-props":
|
|
665
|
+
"view-tag-props": _,
|
|
653
666
|
multi: !0,
|
|
654
|
-
name:
|
|
655
|
-
transition:
|
|
667
|
+
name: r.routerViewName,
|
|
668
|
+
transition: r.transition,
|
|
656
669
|
"scroll-distance": o.scrollDistance,
|
|
657
|
-
"scroll-duration":
|
|
658
|
-
direction:
|
|
659
|
-
width:
|
|
670
|
+
"scroll-duration": r.scrollDuration,
|
|
671
|
+
direction: r.direction,
|
|
672
|
+
width: y.value
|
|
660
673
|
}, null, 8, ["class", "style", "name", "transition", "scroll-distance", "scroll-duration", "direction", "width"]);
|
|
661
674
|
};
|
|
662
675
|
}
|
|
663
676
|
}), Wt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
664
677
|
__proto__: null,
|
|
665
|
-
default:
|
|
678
|
+
default: Vt
|
|
666
679
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
667
680
|
let zt = "fox-";
|
|
668
|
-
const Nt = [], B = /* @__PURE__ */ Object.assign({ "/src/components/card-navigator/index.vue": lt, "/src/components/default-navigator/index.vue":
|
|
681
|
+
const Nt = [], B = /* @__PURE__ */ Object.assign({ "/src/components/card-navigator/index.vue": lt, "/src/components/default-navigator/index.vue": ut, "/src/components/root-navigator/index.vue": Dt, "/src/components/swiper-navigator/index.vue": Wt }), k = [];
|
|
669
682
|
for (const t in B) {
|
|
670
683
|
let e = /src\/components\/(.*)\/index.vue/.exec(t)[1];
|
|
671
684
|
Nt.indexOf(e) === -1 && k.push({
|
package/dist/index.umd.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
(function(s,D){typeof exports=="object"&&typeof module<"u"?module.exports=D(require("vue"),require("@fox-js/fox")):typeof define=="function"&&define.amd?define(["vue","@fox-js/fox"],D):(s=typeof globalThis<"u"?globalThis:s||self,s.FoxNavigation=D(s.Vue,s.Fox))})(this,function(s,D){"use strict";/*!
|
|
2
|
-
* @fox-js/navigation v4.0.1-
|
|
3
|
-
*/const z=Object.freeze(Object.defineProperty({__proto__:null,default:s.defineComponent({__name:"index",props:{routerViewName:{},transition:{type:[Function,Boolean],default:!1}},setup(t){return(e,n)=>{const o=s.resolveComponent("fox-router-view");return s.openBlock(),s.createBlock(o,{class:"fox-card-navigator","view-class":"fox-card-navigator__item","view-active-class":"fox-card-navigator__item-active","view-inactive-class":"fox-card-navigator__item-inactive","transition-name":"fox-card-navigator__trans",transition:e.transition,multi:!0,name:e.routerViewName},null,8,["transition","name"])}}})},Symbol.toStringTag,{value:"Module"})),W=Object.freeze(Object.defineProperty({__proto__:null,default:s.defineComponent({__name:"index",props:{routerViewName:{},transition:{type:[Function,Boolean],default:!0}},setup(t){return(e,n)=>{const o=s.resolveComponent("fox-router-view");return s.openBlock(),s.createBlock(o,{transition:!1,multi:!1,name:e.routerViewName},{default:s.withCtx(({Component:i})=>[s.createVNode(s.Transition,{name:"fox-default-navigator__trans"},{default:s.withCtx(()=>[(s.openBlock(),s.createBlock(s.resolveDynamicComponent(i)))]),_:2},1024)]),_:1},8,["name"])}}})},Symbol.toStringTag,{value:"Module"})),S=10;function N(t,e){return t>e&&t>S?"horizontal":e>t&&e>S?"vertical":""}function A(){const t={startX:0,startY:0,startTime:0,duration:0,moveX:0,moveY:0,deltaX:0,deltaY:0,offsetX:0,offsetY:0,direction:""},e=()=>t.direction==="vertical",n=()=>t.direction==="horizontal",o=()=>{t.deltaX=0,t.deltaY=0,t.offsetX=0,t.offsetY=0,t.direction="",t.startTime=0};return{move:m=>{if(m.touches){const a=m.touches[0];t.deltaX=a.clientX-t.startX,t.deltaY=a.clientY-t.startY,t.moveX=a.clientX,t.moveY=a.clientY}else t.deltaX=m.clientX-t.startX,t.deltaY=m.clientY-t.startY,t.moveX=m.clientX,t.moveY=m.clientY;t.offsetX=Math.abs(t.deltaX),t.offsetY=Math.abs(t.deltaY),t.duration=Date.now()-t.startTime,t.direction||(t.direction=N(t.offsetX,t.offsetY))},start:m=>{if(o(),m.touches){const a=m.touches[0];t.startX=a.clientX,t.startY=a.clientY}else t.startX=m.clientX,t.startY=m.clientY;t.startTime=Date.now()},reset:o,isVertical:e,isHorizontal:n,state:t}}function F(t){return t===window}const k=t=>{const e=s.unref(t);if(F(e)){const n=e.innerWidth,o=e.innerHeight;return{top:0,left:0,right:n,bottom:o,width:n,height:o}}return e&&e.getBoundingClientRect?e.getBoundingClientRect():{top:0,left:0,right:0,bottom:0,width:0,height:0}},j=(t,e,n)=>{e=e??{bubbles:!1,cancelable:!1,detail:void 0};const o=document.createEvent("Events");let i=!0,u=!0;for(let a in e)a==="bubbles"?i=!!e[a]:a==="cancelable"?u=!!e[a]:o[a]=e[a];o.initEvent(t,i,u),(n??document).dispatchEvent(o)},U=15,q=300,H=200;function G(t){t.stopPropagation()}function J(t,e,n=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*n}function R(t,e=0,n,o=H){n==="end"?t.style.transition=`transform ${o}ms linear`:t.style.transition="transform 0ms linear",t.style.transform=`translate3d(${e}px, 0, 0)`}function I(t){t.style.transition="",t.style.transform=""}const K=/^matrix\((.+)\)$/;function O(t){let e=0;const n=t,{transform:o}=window.getComputedStyle(n);if(o){const i=K.exec(o);i&&(e=+i[1].split(/,\s*/)[4])}return e}const P=new WeakMap;function Q(t,e,n,o,i,u=600,m=60){const a={active:!0,startDistance:0,scrollDistance:0,scrollTime:0,moving:!1,transitionEndTrigger:null},x=t.previousSibling,f=A(),v=(_,h,c,T)=>{let g=h+a.startDistance;if(c==="end"){const L=k(_);let l=L.width*e;g<l?g=0:g=L.width,a.transitionEndTrigger=()=>{a.moving=!1,i&&_.classList.remove(i),setTimeout(()=>{x&&I(x),g==0?I(_):j(D.FoxLeaveEnd,{},_),a.moving=!1},m)},x&&R(x,0,"",0),g>0&&typeof o=="function"&&o(),R(_,g,"end",T)}else g<0&&(g=0),R(_,g,"",0)},w=()=>{a.transitionEndTrigger&&(a.transitionEndTrigger(),a.transitionEndTrigger=null)},r=_=>{f.start(_),a.scrollDistance=0,a.moving&&(a.scrollDistance=O(t)),i&&t.classList.add(i),a.transitionEndTrigger=null,a.moving=!0},p=_=>{a.moving=!0,f.move(_),!(f.isVertical()||O(t)===0&&f.state.deltaX<0)&&(G(_),v(t,f.state.deltaX,"",0))},d=()=>{if(f.isVertical()||O(t)===0&&f.state.deltaX<0)return;const h=f.state.deltaX;if(h===0){i&&t.classList.remove(i),a.moving=!1;return}const c=f.state.duration;if(c<q&&Math.abs(h)>U){const g=J(h,c,n);v(t,g,"end",u)}else v(t,h,"end",u)};t.addEventListener("transitionend",w),t.addEventListener("transitioncancel",w),t.addEventListener("touchstart",r),t.addEventListener("touchmove",p),t.addEventListener("touchend",d),t.addEventListener("touchcancel",d),P.set(t,{state:a,transitionend:w,transitioncancel:w,touchstart:r,touchmove:p,touchend:d,touchcancel:d})}function Z(t){const e=P.get(t);e&&(P.delete(t),t.addEventListener("transitionend",e.transitionend),t.addEventListener("transitioncancel",e.transitioncancel),t.addEventListener("touchstart",e.touchstart),t.addEventListener("touchmove",e.touchmove),t.addEventListener("touchend",e.touchend),t.addEventListener("touchcancel",e.touchcancel))}const tt=Object.freeze(Object.defineProperty({__proto__:null,default:s.defineComponent({__name:"index",props:{dragRemove:{type:Boolean,default:!0},removeViewPage:{},removeMoveRatio:{default:.5},momentumReduceRatio:{default:1},resetDelay:{default:120},swipeDuration:{default:60},routerViewName:{},viewTag:{type:[Function,String],default:"div"},transition:{type:[Function,Boolean],default:!0},viewClass:{type:[Function,String],default:"fox-root-navigator__item"}},setup(t){const e=t;let n=null,o=null;function i(r){return(r.params&&r.params.animationType)??"slide"}function u(r){return(r.params&&r.params.dragRemove)??e.dragRemove}const m=(r,p,d,_)=>{if(d.opsType===D.OperationType.Append||p){const h=i(d),c=p?"show":"enter";if(c==="show"&&(h==="pop"||o!=="leave"||(n?i(n):"")==="pop"))return;c==="enter"&&(n=d,o="enter");const T=`fox-root-navigator__${h}-${c}-from`,g=`fox-root-navigator__${h}-${c}-active`;r.classList.add(T),r.classList.add(g)}},a=(r,p,d,_)=>{if(d.opsType===D.OperationType.Append||p){const h=i(d),c=p?"show":"enter";if(c==="show"&&(h==="pop"||o!=="leave"||(n?i(n):"")==="pop"))return;const T=`fox-root-navigator__${h}-${c}-from`,g=`fox-root-navigator__${h}-${c}-to`;r.classList.remove(T),r.classList.add(g)}},x=(r,p,d,_)=>{if(d.opsType===D.OperationType.Append||p){const c=i(d),T=p?"show":"enter";if(T==="enter"&&(n=null,o=null),c!=="pop"){const g=`fox-root-navigator__${c}-${T}-active`,L=`fox-root-navigator__${c}-${T}-to`;r.classList.remove(g),r.classList.remove(L)}}u(d)===!0&&!p&&d.opsType===D.OperationType.Append&&Q(r,e.removeMoveRatio,e.momentumReduceRatio,e.removeViewPage,"fox-root-navigator__item-moving",e.swipeDuration,e.resetDelay)},f=(r,p,d,_)=>{if(d.opsType===D.OperationType.Append||p){const h=i(d),c=p?"hide":"leave";if(c==="hide"&&(h==="pop"||o!=="enter"||(n?i(n):"")==="pop"))return;c==="leave"&&(n=d,o="leave");const T=`fox-root-navigator__${h}-${c}-from`,g=`fox-root-navigator__${h}-${c}-active`;r.classList.add(T),r.classList.add(g)}},v=(r,p,d,_)=>{if(d.opsType===D.OperationType.Append||p){const h=i(d),c=p?"hide":"leave";if(c==="hide"&&(h==="pop"||o!=="enter"||(n?i(n):"")==="pop"))return;const T=`fox-root-navigator__${h}-${c}-from`,g=`fox-root-navigator__${h}-${c}-to`;r.classList.remove(T),r.classList.add(g)}},w=(r,p,d,_)=>{if(d.opsType===D.OperationType.Append||p){const c=i(d),T=p?"hide":"leave";if(T==="leave"&&(n=null,o=null),c!=="pop"){const g=`fox-root-navigator__${c}-${T}-active`,L=`fox-root-navigator__${c}-${T}-to`;r.classList.remove(g),r.classList.remove(L)}}u(d)&&!p&&Z(r)};return(r,p)=>{const d=s.resolveComponent("fox-router-view");return s.openBlock(),s.createBlock(d,{class:"fox-root-navigator","view-class":r.viewClass,"before-enter":m,enter:a,"after-enter":x,"before-leave":f,leave:v,"after-leave":w,multi:!0,name:r.routerViewName,"view-tag":r.viewTag,transition:r.transition},null,8,["view-class","name","view-tag","transition"])}}})},Symbol.toStringTag,{value:"Module"})),et={class:"fox-swiper-navigator"},nt=s.defineComponent({__name:"swiper",props:{width:{},scrollDistance:{},scrollDuration:{},direction:{}},setup(t){const e=t,n=s.computed(()=>{const o={transform:`translate3d(${e.scrollDistance}px, 0, 0)`,width:`${e.width}`};return e.scrollDuration>0&&(o["transition-duration"]=`${e.scrollDuration}ms`),o});return(o,i)=>(s.openBlock(),s.createElementBlock("div",et,[s.createElementVNode("div",{class:"fox-swiper-navigator__inner",style:s.normalizeStyle(n.value)},[s.renderSlot(o.$slots,"default")],4)]))}});let ot=0;function it(){return++ot}const st=15,at=300,rt=200;function ct(t){t.stopPropagation()}function lt(t,e,n=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*n}function V(t,e=0,n,o=rt){n==="end"?t.style.transition=`transform ${o}ms linear`:t.style.transition="transform 0ms linear",t.style.transform=`translate3d(${e}px, 0, 0)`}class dt{width=0;columnWidth=0;max=0;min=0;el=null;swipeDuration=360;transitionEndTrigger=null;moving=!1;startDistance=0;scrollDistance=0;getStartDistance;openPage;isPageOpened;pageOpened;moveRatio=.5;momentumReduceRatio=1;transitionend=null;touchstart=null;touchmove=null;touchend=null;touchcancel=null;constructor(e,n,o,i,u,m){this.getStartDistance=e,this.openPage=n,this.isPageOpened=o,this.pageOpened=i,this.moveRatio=u,this.momentumReduceRatio=m}open(){const e=this.el,n=A(),o=(i,u,m,a)=>{let x=u+this.startDistance;const f=this.columnWidth*this.moveRatio;if(m==="end"){if(u==0){this.moving=!1;return}Math.abs(u)>f?u>0?x=this.startDistance+this.columnWidth:x=this.startDistance-this.columnWidth:x=this.startDistance;let v=-x;v<0?v=0:v>this.width-this.columnWidth&&(v=this.width-this.columnWidth);const w=Math.floor(v/this.columnWidth);this.isPageOpened(w)||this.openPage(w),x=-w*this.columnWidth,a&&a>0&&(this.transitionEndTrigger=()=>{this.moving=!1,this.pageOpened(w)}),V(i,x,"end",a),this.scrollDistance=x}else{if(Math.abs(u)>f){let w=0;if(u>0?w=Math.abs(this.startDistance+this.columnWidth):w=Math.abs(this.startDistance-this.columnWidth),w>=0&&w<this.width){const r=Math.floor(w/this.columnWidth);this.isPageOpened(r)||this.openPage(r)}}let v=-x;v<this.min?v=this.min:v>this.max&&(v=this.max),V(i,-v,"",0)}};this.transitionend=()=>{e.style.transition="",this.transitionEndTrigger&&(this.transitionEndTrigger(),this.transitionEndTrigger=null)},this.touchstart=i=>{this.moving||(n.start(i),this.startDistance=this.getStartDistance(),this.transitionEndTrigger=null,this.moving=!0)},this.touchmove=i=>{n.move(i),!n.isVertical()&&(ct(i),o(e,n.state.deltaX,"",0))},this.touchend=()=>{if(n.isVertical())return;const i=n.state.deltaX;if(i==0)return;const u=n.state.duration;if(u<at&&Math.abs(i)>st){const a=lt(i,u,this.momentumReduceRatio);o(e,a,"end",this.swipeDuration)}else o(e,i,"end",this.swipeDuration)},e.addEventListener("transitionend",this.transitionend),e.addEventListener("touchstart",this.touchstart),e.addEventListener("touchmove",this.touchmove),e.addEventListener("touchend",this.touchend),e.addEventListener("touchcancel",this.touchend)}close(){const e=this.el;this.transitionend&&e.addEventListener("transitionend",this.transitionend),this.touchstart&&e.addEventListener("touchstart",this.touchstart),this.touchmove&&e.addEventListener("touchmove",this.touchmove),this.touchend&&e.addEventListener("touchend",this.touchend),this.touchcancel&&e.addEventListener("touchcancel",this.touchcancel),this.el=null}}function ut(t,e,n,o,i,u){return new dt(t,e,n,o,i,u)}function ft(t){const e=s.unref(t),n=window.getComputedStyle(e,null),o=parseFloat(n.getPropertyValue("padding-left")),i=parseFloat(n.getPropertyValue("padding-right")),u=parseFloat(n.getPropertyValue("padding-top")),m=parseFloat(n.getPropertyValue("padding-bottom"));return{width:e.clientWidth-o-i,height:e.clientHeight-u-m}}const ht=Object.freeze(Object.defineProperty({__proto__:null,default:s.defineComponent({__name:"index",props:{activePath:{},routes:{},height:{default:-1},width:{default:-1},draggable:{type:Boolean,default:!0},openViewPage:{},routerViewName:{},moveRatio:{default:.5},momentumReduceRatio:{default:1},direction:{default:"horizontal"},transition:{type:[Function,Boolean],default:!0},swipeDuration:{default:360},scrollDuration:{},customClass:{},customStyle:{}},emits:["update:activePath"],setup(t,{emit:e}){const n=t,o=s.reactive({scrollDistance:0,index:-1,openedIndexList:[],width:n.width,height:n.height}),i=e,u=()=>o.scrollDistance,m=l=>{if(o.openedIndexList.indexOf(l)===-1){o.openedIndexList.push(l);const E=n.routes[l];try{n.openViewPage(E,l)}catch(y){console.error(y)}}},a=l=>o.openedIndexList.indexOf(l)!==-1,x=l=>{o.index=l,o.width>0?o.scrollDistance=-o.index*o.width:o.scrollDistance=0;const E=n.routes[l];i("update:activePath",E.path)};let f=null;n.draggable&&(f=ut(u,m,a,x,n.moveRatio,n.momentumReduceRatio));let v=null;s.onMounted(()=>{const l=h(),E=()=>{const y=ft(l);w(n.activePath,n.routes,y.width,y.height,n.swipeDuration,n.direction)};if(window.ResizeObserver&&(v=new window.ResizeObserver(E),v.observe(l)),E(),f){const y=T();f.el=y,f.open()}}),s.onBeforeUnmount(()=>{v&&(v.disconnect(),v=null),f&&f.close()}),s.watch([()=>n.activePath,()=>n.routes,()=>n.width,()=>n.height,()=>n.swipeDuration,()=>n.direction],([l,E,y,b,M,C])=>{const X=y<=0?o.width:y,$=b<=0?o.height:b;w(l,E,X,$,M,C)});const w=(l,E,y,b,M,C="horizontal")=>{const X=l;if(o.index=E.findIndex($=>$.path===X),C==="horizontal"){const $=y;if($>0){o.width=y;const gt=$*n.routes.length,vt=-$/3,_t=$*(E.length-1)+$/3;f&&(f.columnWidth=$,f.width=gt,f.min=vt,f.max=_t),o.index!==-1&&(o.openedIndexList.push(o.index),o.scrollDistance=-$*o.index)}}f&&(f.swipeDuration=M)},r=`fox-swiper-navigator-${it()}`,p=s.computed(()=>{const l=[r];return n.customClass&&l.push(n.customClass),l}),d=s.computed(()=>{const l={},E=o.width>0?o.width:n.width;E>0&&(l.width=`${E}px`);const y=o.height>0?o.height:n.height;return y>0&&(l.height=`${y}px`),n.customStyle&&Object.assign(l,n.customStyle),l});let _=null;function h(){return _||(_=document.querySelector(`.${r}`),_)}let c=null;function T(){return c||(c=document.querySelector(`.${r}>.fox-swiper-navigator__inner`),c)}const g=s.computed(()=>o.width>0?`${o.width*n.routes.length}px`:"100%"),L=(l,E)=>{const y=n.routes.findIndex(b=>{const M=l.path??l.name??"";return b.path==M});return o.width<=0?{}:{style:{left:`${y*o.width}px`,width:`${o.width}px`}}};return(l,E)=>{const y=s.resolveComponent("fox-router-view");return s.openBlock(),s.createBlock(y,{class:s.normalizeClass(p.value),style:s.normalizeStyle(d.value),"view-class":"fox-swiper-navigator__item",tag:nt,"view-tag-props":L,multi:!0,name:l.routerViewName,transition:l.transition,"scroll-distance":o.scrollDistance,"scroll-duration":l.scrollDuration,direction:l.direction,width:g.value},null,8,["class","style","name","transition","scroll-distance","scroll-duration","direction","width"])}}})},Symbol.toStringTag,{value:"Module"}));let mt="fox-";const pt=[],B=Object.assign({"/src/components/card-navigator/index.vue":z,"/src/components/default-navigator/index.vue":W,"/src/components/root-navigator/index.vue":tt,"/src/components/swiper-navigator/index.vue":ht}),Y=[];for(const t in B){let e=/src\/components\/(.*)\/index.vue/.exec(t)[1];pt.indexOf(e)===-1&&Y.push({name:e,component:B[t].default})}return{install(t){Y.forEach(e=>{t.component(`${mt}${e.name}`,e.component)})}}});
|
|
2
|
+
* @fox-js/navigation v4.0.1-15 Sat Jun 15 2024 16:18:22 GMT+0800 (中国标准时间)
|
|
3
|
+
*/const z=Object.freeze(Object.defineProperty({__proto__:null,default:s.defineComponent({__name:"index",props:{routerViewName:{},transition:{type:[Function,Boolean],default:!1}},setup(t){return(e,n)=>{const o=s.resolveComponent("fox-router-view");return s.openBlock(),s.createBlock(o,{class:"fox-card-navigator","view-class":"fox-card-navigator__item","view-active-class":"fox-card-navigator__item-active","view-inactive-class":"fox-card-navigator__item-inactive","transition-name":"fox-card-navigator__trans",transition:e.transition,multi:!0,name:e.routerViewName},null,8,["transition","name"])}}})},Symbol.toStringTag,{value:"Module"})),W=Object.freeze(Object.defineProperty({__proto__:null,default:s.defineComponent({__name:"index",props:{routerViewName:{},transition:{type:[Function,Boolean],default:!0}},setup(t){return(e,n)=>{const o=s.resolveComponent("fox-router-view");return s.openBlock(),s.createBlock(o,{transition:!1,multi:!1,name:e.routerViewName},{default:s.withCtx(({Component:i})=>[s.createVNode(s.Transition,{name:"fox-default-navigator__trans"},{default:s.withCtx(()=>[(s.openBlock(),s.createBlock(s.resolveDynamicComponent(i)))]),_:2},1024)]),_:1},8,["name"])}}})},Symbol.toStringTag,{value:"Module"})),C=10;function N(t,e){return t>e&&t>C?"horizontal":e>t&&e>C?"vertical":""}function S(){const t={startX:0,startY:0,startTime:0,duration:0,moveX:0,moveY:0,deltaX:0,deltaY:0,offsetX:0,offsetY:0,direction:""},e=()=>t.direction==="vertical",n=()=>t.direction==="horizontal",o=()=>{t.deltaX=0,t.deltaY=0,t.offsetX=0,t.offsetY=0,t.direction="",t.startTime=0};return{move:p=>{if(p.touches){const m=p.touches[0];t.deltaX=m.clientX-t.startX,t.deltaY=m.clientY-t.startY,t.moveX=m.clientX,t.moveY=m.clientY}else t.deltaX=p.clientX-t.startX,t.deltaY=p.clientY-t.startY,t.moveX=p.clientX,t.moveY=p.clientY;t.offsetX=Math.abs(t.deltaX),t.offsetY=Math.abs(t.deltaY),t.duration=Date.now()-t.startTime,t.direction||(t.direction=N(t.offsetX,t.offsetY))},start:p=>{if(o(),p.touches){const m=p.touches[0];t.startX=m.clientX,t.startY=m.clientY}else t.startX=p.clientX,t.startY=p.clientY;t.startTime=Date.now()},reset:o,isVertical:e,isHorizontal:n,state:t}}function F(t){return t===window}const k=t=>{const e=s.unref(t);if(F(e)){const n=e.innerWidth,o=e.innerHeight;return{top:0,left:0,right:n,bottom:o,width:n,height:o}}return e&&e.getBoundingClientRect?e.getBoundingClientRect():{top:0,left:0,right:0,bottom:0,width:0,height:0}},j=(t,e,n)=>{e=e??{bubbles:!1,cancelable:!1,detail:void 0};const o=document.createEvent("Events");let i=!0,h=!0;for(let m in e)m==="bubbles"?i=!!e[m]:m==="cancelable"?h=!!e[m]:o[m]=e[m];o.initEvent(t,i,h),(n??document).dispatchEvent(o)},U=15,q=300,H=200;function G(t){t.stopPropagation()}function J(t,e,n=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*n}function R(t,e=0,n,o=H){n==="end"?t.style.transition=`transform ${o}ms linear`:t.style.transition="transform 0ms linear",t.style.transform=`translate3d(${e}px, 0, 0)`}function I(t){t.style.transition="",t.style.transform=""}const K=/^matrix\((.+)\)$/;function O(t){let e=0;const n=t,{transform:o}=window.getComputedStyle(n);if(o){const i=K.exec(o);i&&(e=+i[1].split(/,\s*/)[4])}return e}const A=new WeakMap;function Q(t,e,n,o,i,h=600,p=60,m=null){const l={active:!0,startDistance:0,scrollDistance:0,scrollTime:0,moving:!1,dragging:!1,transitionEndTrigger:null},_=t.previousSibling,d=S(),y=(u,r,v,E)=>{let w=r+l.startDistance;if(v==="end"){const c=k(u);let T=c.width*e;w<T?w=0:w=c.width,l.transitionEndTrigger=()=>{l.moving=!1,i&&u.classList.remove(i),setTimeout(()=>{_&&I(_),w==0?I(u):j(D.FoxLeaveEnd,{},u),l.moving=!1},p)},_&&R(_,0,"",0),w>0&&typeof o=="function"&&o(),R(u,w,"end",E)}else w<0&&(w=0),R(u,w,"",0)},a=()=>{l.transitionEndTrigger&&(l.transitionEndTrigger(),l.transitionEndTrigger=null)},g=u=>{if(d.start(u),l.draging=m?m(t,d.state.startX,d.state.startY):!0,!l.draging){d.reset();return}l.scrollDistance=0,l.moving&&(l.scrollDistance=O(t)),i&&t.classList.add(i),l.transitionEndTrigger=null,l.moving=!0},f=u=>{!l.draging||(l.moving=!0,d.move(u),d.isVertical())||O(t)===0&&d.state.deltaX<0||(G(u),y(t,d.state.deltaX,"",0))},b=()=>{if(!l.draging||(l.draging=!1,d.isVertical())||O(t)===0&&d.state.deltaX<0)return;const r=d.state.deltaX;if(r===0){i&&t.classList.remove(i),l.moving=!1;return}const v=d.state.duration;if(v<q&&Math.abs(r)>U){const w=J(r,v,n);y(t,w,"end",h)}else y(t,r,"end",h)};t.addEventListener("transitionend",a),t.addEventListener("transitioncancel",a),t.addEventListener("touchstart",g),t.addEventListener("touchmove",f),t.addEventListener("touchend",b),t.addEventListener("touchcancel",b),A.set(t,{state:l,transitionend:a,transitioncancel:a,touchstart:g,touchmove:f,touchend:b,touchcancel:b})}function Z(t){const e=A.get(t);e&&(A.delete(t),t.addEventListener("transitionend",e.transitionend),t.addEventListener("transitioncancel",e.transitioncancel),t.addEventListener("touchstart",e.touchstart),t.addEventListener("touchmove",e.touchmove),t.addEventListener("touchend",e.touchend),t.addEventListener("touchcancel",e.touchcancel))}const tt=Object.freeze(Object.defineProperty({__proto__:null,default:s.defineComponent({__name:"index",props:{dragRemove:{type:Boolean,default:!0},removeViewPage:{},removeMoveRatio:{default:.5},momentumReduceRatio:{default:1},resetDelay:{default:120},swipeDuration:{default:60},draggableArea:{},routerViewName:{},viewTag:{type:[Function,String],default:"div"},transition:{type:[Function,Boolean],default:!0},viewClass:{type:[Function,String],default:"fox-root-navigator__item"}},setup(t){const e=t;let n=null,o=null;function i(a){return(a.params&&a.params.animationType)??"slide"}function h(a){return(a.params&&a.params.dragRemove)??e.dragRemove}const p=(a,g,f,b)=>{if(f.opsType===D.OperationType.Append||g){const u=i(f),r=g?"show":"enter";if(r==="show"&&(u==="pop"||o!=="leave"||(n?i(n):"")==="pop"))return;r==="enter"&&(n=f,o="enter");const v=`fox-root-navigator__${u}-${r}-from`,E=`fox-root-navigator__${u}-${r}-active`;a.classList.add(v),a.classList.add(E)}},m=(a,g,f,b)=>{if(f.opsType===D.OperationType.Append||g){const u=i(f),r=g?"show":"enter";if(r==="show"&&(u==="pop"||o!=="leave"||(n?i(n):"")==="pop"))return;const v=`fox-root-navigator__${u}-${r}-from`,E=`fox-root-navigator__${u}-${r}-to`;a.classList.remove(v),a.classList.add(E)}},l=(a,g,f,b)=>{if(f.opsType===D.OperationType.Append||g){const r=i(f),v=g?"show":"enter";if(v==="enter"&&(n=null,o=null),r!=="pop"){const E=`fox-root-navigator__${r}-${v}-active`,w=`fox-root-navigator__${r}-${v}-to`;a.classList.remove(E),a.classList.remove(w)}}if(h(f)===!0&&!g&&f.opsType===D.OperationType.Append){let r=null;e.draggableArea&&(r=function(v,E,w){const c=E-v.offsetLeft,T=w-v.offsetTop;return!(e.draggableArea?.left&&c<e.draggableArea?.left||e.draggableArea?.right&&c>e.draggableArea?.right||e.draggableArea?.top&&T<e.draggableArea?.top||e.draggableArea?.bottom&&T>e.draggableArea?.bottom)}),Q(a,e.removeMoveRatio,e.momentumReduceRatio,e.removeViewPage,"fox-root-navigator__item-moving",e.swipeDuration,e.resetDelay,r)}},_=(a,g,f,b)=>{if(f.opsType===D.OperationType.Append||g){const u=i(f),r=g?"hide":"leave";if(r==="hide"&&(u==="pop"||o!=="enter"||(n?i(n):"")==="pop"))return;r==="leave"&&(n=f,o="leave");const v=`fox-root-navigator__${u}-${r}-from`,E=`fox-root-navigator__${u}-${r}-active`;a.classList.add(v),a.classList.add(E)}},d=(a,g,f,b)=>{if(f.opsType===D.OperationType.Append||g){const u=i(f),r=g?"hide":"leave";if(r==="hide"&&(u==="pop"||o!=="enter"||(n?i(n):"")==="pop"))return;const v=`fox-root-navigator__${u}-${r}-from`,E=`fox-root-navigator__${u}-${r}-to`;a.classList.remove(v),a.classList.add(E)}},y=(a,g,f,b)=>{if(f.opsType===D.OperationType.Append||g){const r=i(f),v=g?"hide":"leave";if(v==="leave"&&(n=null,o=null),r!=="pop"){const E=`fox-root-navigator__${r}-${v}-active`,w=`fox-root-navigator__${r}-${v}-to`;a.classList.remove(E),a.classList.remove(w)}}h(f)&&!g&&Z(a)};return(a,g)=>{const f=s.resolveComponent("fox-router-view");return s.openBlock(),s.createBlock(f,{class:"fox-root-navigator","view-class":a.viewClass,"before-enter":p,enter:m,"after-enter":l,"before-leave":_,leave:d,"after-leave":y,multi:!0,name:a.routerViewName,"view-tag":a.viewTag,transition:a.transition},null,8,["view-class","name","view-tag","transition"])}}})},Symbol.toStringTag,{value:"Module"})),et={class:"fox-swiper-navigator"},nt=s.defineComponent({__name:"swiper",props:{width:{},scrollDistance:{},scrollDuration:{},direction:{}},setup(t){const e=t,n=s.computed(()=>{const o={transform:`translate3d(${e.scrollDistance}px, 0, 0)`,width:`${e.width}`};return e.scrollDuration>0&&(o["transition-duration"]=`${e.scrollDuration}ms`),o});return(o,i)=>(s.openBlock(),s.createElementBlock("div",et,[s.createElementVNode("div",{class:"fox-swiper-navigator__inner",style:s.normalizeStyle(n.value)},[s.renderSlot(o.$slots,"default")],4)]))}});let ot=0;function it(){return++ot}const st=15,at=300,rt=200;function ct(t){t.stopPropagation()}function lt(t,e,n=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*n}function V(t,e=0,n,o=rt){n==="end"?t.style.transition=`transform ${o}ms linear`:t.style.transition="transform 0ms linear",t.style.transform=`translate3d(${e}px, 0, 0)`}class dt{width=0;columnWidth=0;max=0;min=0;el=null;swipeDuration=360;transitionEndTrigger=null;moving=!1;startDistance=0;scrollDistance=0;getStartDistance;openPage;isPageOpened;pageOpened;moveRatio=.5;momentumReduceRatio=1;transitionend=null;touchstart=null;touchmove=null;touchend=null;touchcancel=null;constructor(e,n,o,i,h,p){this.getStartDistance=e,this.openPage=n,this.isPageOpened=o,this.pageOpened=i,this.moveRatio=h,this.momentumReduceRatio=p}open(){const e=this.el,n=S(),o=(i,h,p,m)=>{let l=h+this.startDistance;const _=this.columnWidth*this.moveRatio;if(p==="end"){if(h==0){this.moving=!1;return}Math.abs(h)>_?h>0?l=this.startDistance+this.columnWidth:l=this.startDistance-this.columnWidth:l=this.startDistance;let d=-l;d<0?d=0:d>this.width-this.columnWidth&&(d=this.width-this.columnWidth);const y=Math.floor(d/this.columnWidth);this.isPageOpened(y)||this.openPage(y),l=-y*this.columnWidth,m&&m>0&&(this.transitionEndTrigger=()=>{this.moving=!1,this.pageOpened(y)}),V(i,l,"end",m),this.scrollDistance=l}else{if(Math.abs(h)>_){let y=0;if(h>0?y=Math.abs(this.startDistance+this.columnWidth):y=Math.abs(this.startDistance-this.columnWidth),y>=0&&y<this.width){const a=Math.floor(y/this.columnWidth);this.isPageOpened(a)||this.openPage(a)}}let d=-l;d<this.min?d=this.min:d>this.max&&(d=this.max),V(i,-d,"",0)}};this.transitionend=()=>{e.style.transition="",this.transitionEndTrigger&&(this.transitionEndTrigger(),this.transitionEndTrigger=null)},this.touchstart=i=>{this.moving||(n.start(i),this.startDistance=this.getStartDistance(),this.transitionEndTrigger=null,this.moving=!0)},this.touchmove=i=>{n.move(i),!n.isVertical()&&(ct(i),o(e,n.state.deltaX,"",0))},this.touchend=()=>{if(n.isVertical())return;const i=n.state.deltaX;if(i==0)return;const h=n.state.duration;if(h<at&&Math.abs(i)>st){const m=lt(i,h,this.momentumReduceRatio);o(e,m,"end",this.swipeDuration)}else o(e,i,"end",this.swipeDuration)},e.addEventListener("transitionend",this.transitionend),e.addEventListener("touchstart",this.touchstart),e.addEventListener("touchmove",this.touchmove),e.addEventListener("touchend",this.touchend),e.addEventListener("touchcancel",this.touchend)}close(){const e=this.el;this.transitionend&&e.addEventListener("transitionend",this.transitionend),this.touchstart&&e.addEventListener("touchstart",this.touchstart),this.touchmove&&e.addEventListener("touchmove",this.touchmove),this.touchend&&e.addEventListener("touchend",this.touchend),this.touchcancel&&e.addEventListener("touchcancel",this.touchcancel),this.el=null}}function ut(t,e,n,o,i,h){return new dt(t,e,n,o,i,h)}function ft(t){const e=s.unref(t),n=window.getComputedStyle(e,null),o=parseFloat(n.getPropertyValue("padding-left")),i=parseFloat(n.getPropertyValue("padding-right")),h=parseFloat(n.getPropertyValue("padding-top")),p=parseFloat(n.getPropertyValue("padding-bottom"));return{width:e.clientWidth-o-i,height:e.clientHeight-h-p}}const ht=Object.freeze(Object.defineProperty({__proto__:null,default:s.defineComponent({__name:"index",props:{activePath:{},routes:{},height:{default:-1},width:{default:-1},draggable:{type:Boolean,default:!0},openViewPage:{},routerViewName:{},moveRatio:{default:.5},momentumReduceRatio:{default:1},direction:{default:"horizontal"},transition:{type:[Function,Boolean],default:!0},swipeDuration:{default:360},scrollDuration:{},customClass:{},customStyle:{}},emits:["update:activePath"],setup(t,{emit:e}){const n=t,o=s.reactive({scrollDistance:0,index:-1,openedIndexList:[],width:n.width,height:n.height}),i=e,h=()=>o.scrollDistance,p=c=>{if(o.openedIndexList.indexOf(c)===-1){o.openedIndexList.push(c);const T=n.routes[c];try{n.openViewPage(T,c)}catch(x){console.error(x)}}},m=c=>o.openedIndexList.indexOf(c)!==-1,l=c=>{o.index=c,o.width>0?o.scrollDistance=-o.index*o.width:o.scrollDistance=0;const T=n.routes[c];i("update:activePath",T.path)};let _=null;n.draggable&&(_=ut(h,p,m,l,n.moveRatio,n.momentumReduceRatio));let d=null;s.onMounted(()=>{const c=u(),T=()=>{const x=ft(c);y(n.activePath,n.routes,x.width,x.height,n.swipeDuration,n.direction)};if(window.ResizeObserver&&(d=new window.ResizeObserver(T),d.observe(c)),T(),_){const x=v();_.el=x,_.open()}}),s.onBeforeUnmount(()=>{d&&(d.disconnect(),d=null),_&&_.close()}),s.watch([()=>n.activePath,()=>n.routes,()=>n.width,()=>n.height,()=>n.swipeDuration,()=>n.direction],([c,T,x,$,M,P])=>{const X=x<=0?o.width:x,L=$<=0?o.height:$;y(c,T,X,L,M,P)});const y=(c,T,x,$,M,P="horizontal")=>{const X=c;if(o.index=T.findIndex(L=>L.path===X),P==="horizontal"){const L=x;if(L>0){o.width=x;const gt=L*n.routes.length,vt=-L/3,_t=L*(T.length-1)+L/3;_&&(_.columnWidth=L,_.width=gt,_.min=vt,_.max=_t),o.index!==-1&&(o.openedIndexList.push(o.index),o.scrollDistance=-L*o.index)}}_&&(_.swipeDuration=M)},a=`fox-swiper-navigator-${it()}`,g=s.computed(()=>{const c=[a];return n.customClass&&c.push(n.customClass),c}),f=s.computed(()=>{const c={},T=o.width>0?o.width:n.width;T>0&&(c.width=`${T}px`);const x=o.height>0?o.height:n.height;return x>0&&(c.height=`${x}px`),n.customStyle&&Object.assign(c,n.customStyle),c});let b=null;function u(){return b||(b=document.querySelector(`.${a}`),b)}let r=null;function v(){return r||(r=document.querySelector(`.${a}>.fox-swiper-navigator__inner`),r)}const E=s.computed(()=>o.width>0?`${o.width*n.routes.length}px`:"100%"),w=(c,T)=>{const x=n.routes.findIndex($=>{const M=c.path??c.name??"";return $.path==M});return o.width<=0?{}:{style:{left:`${x*o.width}px`,width:`${o.width}px`}}};return(c,T)=>{const x=s.resolveComponent("fox-router-view");return s.openBlock(),s.createBlock(x,{class:s.normalizeClass(g.value),style:s.normalizeStyle(f.value),"view-class":"fox-swiper-navigator__item",tag:nt,"view-tag-props":w,multi:!0,name:c.routerViewName,transition:c.transition,"scroll-distance":o.scrollDistance,"scroll-duration":c.scrollDuration,direction:c.direction,width:E.value},null,8,["class","style","name","transition","scroll-distance","scroll-duration","direction","width"])}}})},Symbol.toStringTag,{value:"Module"}));let mt="fox-";const pt=[],Y=Object.assign({"/src/components/card-navigator/index.vue":z,"/src/components/default-navigator/index.vue":W,"/src/components/root-navigator/index.vue":tt,"/src/components/swiper-navigator/index.vue":ht}),B=[];for(const t in Y){let e=/src\/components\/(.*)\/index.vue/.exec(t)[1];pt.indexOf(e)===-1&&B.push({name:e,component:Y[t].default})}return{install(t){B.forEach(e=>{t.component(`${mt}${e.name}`,e.component)})}}});
|