@fox-js/navigation 4.0.1-5 → 4.0.1-7
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/README.md +4 -0
- package/dist/index.cjs.js +2 -2
- package/dist/index.d.ts +4 -1
- package/dist/index.esm.js +361 -246
- package/dist/index.umd.js +3 -3
- package/package.json +11 -14
package/README.md
CHANGED
|
@@ -93,6 +93,8 @@ pageHelper.append({
|
|
|
93
93
|
| remove-page | 关闭顶层页面方法 | Function | |
|
|
94
94
|
| router-view-name | router view名称 | String | `default` |
|
|
95
95
|
| view-tag | view tag标签 | Function/String | `div` |
|
|
96
|
+
| remove-move-ratio | 触发移除页面的移动比例(相对页面宽度) | Number | 0.5 |
|
|
97
|
+
| momentum-reduce-ratio | 惯性削减比例 | Number | 1 |
|
|
96
98
|
|
|
97
99
|
|
|
98
100
|
|
|
@@ -280,6 +282,8 @@ onMounted(() => {
|
|
|
280
282
|
| drag | 是否支持拖曳 | Boolean | |
|
|
281
283
|
| swipe-duration | 滑动页面动画时间 | Number ||
|
|
282
284
|
| scroll-time | 切换页面动画时间 | Number | |
|
|
285
|
+
| move-ratio | 触发页面移动的比例(相对页面宽度) | Number | 0.5 |
|
|
286
|
+
| momentum-reduce-ratio | 惯性削减比例 | Number | 1 |
|
|
283
287
|
|
|
284
288
|
|
|
285
289
|
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use strict";/*!
|
|
2
|
-
* @fox-js/navigation v4.0.1-
|
|
3
|
-
*/const o=require("vue"),O=o.defineComponent({__name:"index",props:{routerViewName:null,transition:{type:[Object,Boolean],default:!1}},setup(t){const e=t;return(n,s)=>{const f=o.resolveComponent("fox-router-view");return o.openBlock(),o.createBlock(f,{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"])}}});const P=Object.freeze(Object.defineProperty({__proto__:null,default:O},Symbol.toStringTag,{value:"Module"})),C=o.defineComponent({__name:"index",props:{routerViewName:null,transition:{type:[Object,Boolean],default:!0}},setup(t){const e=t;return(n,s)=>{const f=o.resolveComponent("fox-router-view");return o.openBlock(),o.createBlock(f,{transition:!1,multi:!1,name:e.routerViewName},{default:o.withCtx(({Component:d})=>[o.createVNode(o.Transition,{name:"fox-default-navigator__trans"},{default:o.withCtx(()=>[(o.openBlock(),o.createBlock(o.resolveDynamicComponent(d)))]),_:2},1024)]),_:1},8,["name"])}}});const I=Object.freeze(Object.defineProperty({__proto__:null,default:C},Symbol.toStringTag,{value:"Module"})),$=10;function S(t,e){return t>e&&t>$?"horizontal":e>t&&e>$?"vertical":""}function L(){const t=o.ref(0),e=o.ref(0),n=o.ref(0),s=o.ref(0),f=o.ref(0),d=o.ref(0),m=o.ref(0),_=o.ref(0),h=o.ref(0),c=o.ref(0),i=o.ref(""),r=()=>i.value==="vertical",g=()=>i.value==="horizontal",a=()=>{m.value=0,_.value=0,h.value=0,c.value=0,i.value="",n.value=0};return{move:u=>{const p=u.touches[0];m.value=p.clientX-t.value,_.value=p.clientY-e.value,f.value=p.clientX,d.value=p.clientY,h.value=Math.abs(m.value),c.value=Math.abs(_.value),s.value=Date.now()-n.value,i.value||(i.value=S(h.value,c.value))},start:u=>{a(),t.value=u.touches[0].clientX,e.value=u.touches[0].clientY,n.value=Date.now()},reset:a,startX:t,startY:e,startTime:n,duration:s,moveX:f,moveY:d,deltaX:m,deltaY:_,offsetX:h,offsetY:c,direction:i,isVertical:r,isHorizontal:g}}function B(t){return t===window}const V=t=>{const e=o.unref(t);if(B(e)){const n=e.innerWidth,s=e.innerHeight;return{top:0,left:0,right:n,bottom:s,width:n,height:s}}return e&&e.getBoundingClientRect?e.getBoundingClientRect():{top:0,left:0,right:0,bottom:0,width:0,height:0}},W=15,z=300,N=200;function k(t){t.stopPropagation()}function j(t,e){(typeof t.cancelable!="boolean"||t.cancelable)&&t.preventDefault(),e&&k(t)}function X(t,e){return t=Math.abs(t/e)/.003*(t<0?-1:1),t}function T(t,e=0,n,s=N){n==="end"?t.style.transition=`transform ${s}ms cubic-bezier(0.17, 0.89, 0.45, 1)`:t.style.transition="transform 0ms cubic-bezier(0.17, 0.89, 0.45, 1)",t.style.transform=`translate3d(${e}px, 0, 0)`}const D=new WeakMap;function A(t,e,n=500,s,f=1e3){const d={active:!0,startDistance:0,scrollDistance:0,scrollTime:0,moving:!1,transitionEndTrigger:null},m=t.previousSibling,_=L(),h=(a,v,l,u)=>{let p=v+d.startDistance;if(l==="end"){const x=V(a);let w=x.width/3;p<w?p=0:p=x.width;let y=!1;u&&u>0&&(y=!0,d.transitionEndTrigger=()=>{d.moving=!1,s&&a.classList.remove(s),p>0&&typeof e=="function"&&e()}),T(a,p,"end",u),m&&T(m,0,"",0),!y&&p>0&&typeof e=="function"&&e()}else p<0&&(p=0),T(a,p,"",0)},c=()=>{t.style.transform="",t.style.transition="",d.transitionEndTrigger?(d.transitionEndTrigger(),d.transitionEndTrigger=null,m&&setTimeout(()=>{m&&(m.style.transform="",m.style.transition="")},n)):m&&(m.style.transform="",m.style.transition="")},i=a=>{if(_.start(a),d.moving){const v=t,{transform:l}=window.getComputedStyle(v);d.scrollDistance=+l.slice(7,l.length-1).split(", ")[5]}s&&t.classList.add(s),d.startDistance=d.scrollDistance,d.transitionEndTrigger=null,d.moving=!0},r=a=>{d.moving=!0,_.move(a),_.isHorizontal()&&j(a,!0),h(t,_.deltaX.value,"",0)},g=()=>{const a=_.deltaX.value;if(a==0){s&&t.classList.remove(s);return}const v=_.duration.value;if(v<z&&Math.abs(a)>W){const u=X(a,v);h(t,u,"end",f)}else h(t,a,"end",f)};t.addEventListener("transitionend",c),t.addEventListener("touchstart",i),t.addEventListener("touchmove",r),t.addEventListener("touchend",g),t.addEventListener("touchcancel",g),D.set(t,{state:d,transitionend:c,touchstart:i,touchmove:r,touchend:g,touchcancel:g})}function U(t){const e=D.get(t);e&&(D.delete(t),t.addEventListener("transitionend",e.transitionend),t.addEventListener("touchstart",e.touchstart),t.addEventListener("touchmove",e.touchmove),t.addEventListener("touchend",e.touchend),t.addEventListener("touchcancel",e.touchcancel))}const R=o.defineComponent({__name:"index",props:{dragRemove:{type:Boolean,default:!0},removeViewPage:null,removeViewPageDuration:{default:500},routerViewName:null,viewTag:{default:"div"},transition:{type:[Object,Boolean],default:!0},viewClass:{default:"fox-root-navigator__item"}},setup(t){const e=t;function n(c){return(c.params&&c.params.animationType)??"slide"}const s=(c,i,r,g)=>{if(r.opsType===3||i){const a=n(r);if(a==="pop"&&i)return;const v=i?"show":"enter",l=`fox-root-navigator__${a}-${v}-from`,u=`fox-root-navigator__${a}-${v}-active`;c.classList.add(l),c.classList.add(u)}},f=(c,i,r,g)=>{if(r.opsType===3||i){const a=n(r);if(a==="pop"&&i)return;const v=i?"show":"enter",l=`fox-root-navigator__${a}-${v}-from`,u=`fox-root-navigator__${a}-${v}-to`;c.classList.remove(l),c.classList.add(u)}},d=(c,i,r,g)=>{if(r.opsType===3||i){const a=n(r);if(a!=="pop"||!i){const v=i?"show":"enter",l=`fox-root-navigator__${a}-${v}-active`,u=`fox-root-navigator__${a}-${v}-to`;c.classList.remove(l),c.classList.remove(u)}}e.dragRemove&&!i&&r.opsType===3&&A(c,e.removeViewPage,e.removeViewPageDuration,"fox-root-navigator__item-moving",1e3)},m=(c,i,r,g)=>{if(r.opsType===3||i){const a=n(r);if(a==="pop"&&i)return;const v=i?"hide":"leave",l=`fox-root-navigator__${a}-${v}-from`,u=`fox-root-navigator__${a}-${v}-active`;c.classList.add(l),c.classList.add(u)}},_=(c,i,r,g)=>{if(r.opsType===3||i){const a=n(r);if(a==="pop"&&i)return;const v=i?"hide":"leave",l=`fox-root-navigator__${a}-${v}-from`,u=`fox-root-navigator__${a}-${v}-to`;c.classList.remove(l),c.classList.add(u)}},h=(c,i,r,g)=>{if(r.opsType===3||i){const a=n(r);if(a!=="pop"||!i){const v=i?"hide":"leave",l=`fox-root-navigator__${a}-${v}-active`,u=`fox-root-navigator__${a}-${v}-to`;c.classList.remove(l),c.classList.remove(u)}}e.dragRemove&&!i&&U(c)};return(c,i)=>{const r=o.resolveComponent("fox-router-view");return o.openBlock(),o.createBlock(r,{class:"fox-root-navigator","view-class":t.viewClass,"before-enter":s,enter:f,"after-enter":d,"before-leave":m,leave:_,"after-leave":h,multi:!0,name:e.routerViewName,"view-tag":e.viewTag,transition:e.transition},null,8,["view-class","name","view-tag","transition"])}}});const Y=Object.freeze(Object.defineProperty({__proto__:null,default:R},Symbol.toStringTag,{value:"Module"})),q={class:"fox-swiper-navigator"},H=o.defineComponent({__name:"swiper",props:{width:null,scrollDistance:null,scrollTime:null},setup(t){const e=t,n=o.computed(()=>({transform:`translate3d(${e.scrollDistance}px, 0, 0)`,width:`${e.width}`}));return(s,f)=>(o.openBlock(),o.createElementBlock("div",q,[o.createElementVNode("div",{class:"fox-swiper-navigator__inner",style:o.normalizeStyle(o.unref(n))},[o.renderSlot(s.$slots,"default")],4)]))}});let F=0;function G(){return++F}const J=15,K=300,Q=200;function Z(t){t.stopPropagation()}function tt(t,e){(typeof t.cancelable!="boolean"||t.cancelable)&&t.preventDefault(),e&&Z(t)}function et(t,e){return t=Math.abs(t/e)/.003*(t<0?-1:1),t}function E(t,e=0,n,s=Q){n==="end"?t.style.transition=`transform ${s}ms cubic-bezier(0.17, 0.89, 0.45, 1)`:t.style.transition="transform 0ms cubic-bezier(0.17, 0.89, 0.45, 1)",t.style.transform=`translate3d(${e}px, 0, 0)`}class nt{width=0;columnWidth=0;max=0;min=0;el=null;swipeDuration=360;transitionEndTrigger=null;moving=!1;startDistance=0;scrollDistance=0;getStartDistance;openPage;isPageOpened;pageOpened;transitionend=null;touchstart=null;touchmove=null;touchend=null;touchcancel=null;constructor(e,n,s,f){this.getStartDistance=e,this.openPage=n,this.isPageOpened=s,this.pageOpened=f}open(){const e=this.el,n=L(),s=(f,d,m,_)=>{let h=d+this.startDistance;const c=this.columnWidth/3;if(m==="end"){if(h==0){this.moving=!1;return}Math.abs(d)>c&&(d>0?h=this.startDistance+this.columnWidth:h=this.startDistance-this.columnWidth);let i=-h;i<0?i=0:i>this.width-this.columnWidth&&(i=this.width-this.columnWidth);const r=Math.floor(i/this.columnWidth);this.isPageOpened(r)||this.openPage(r),h=-r*this.columnWidth,_&&_>0&&(this.transitionEndTrigger=()=>{this.moving=!1,this.pageOpened(r)}),E(f,h,"end",_),this.scrollDistance=h}else{if(Math.abs(d)>c){let r=0;if(d>0?r=Math.abs(this.startDistance+this.columnWidth):r=Math.abs(this.startDistance-this.columnWidth),r>=0&&r<this.width){const g=Math.floor(r/this.columnWidth);this.isPageOpened(g)||this.openPage(g)}}let i=-h;i<this.min?i=this.min:i>this.max&&(i=this.max),E(f,-i,"",0)}};this.transitionend=()=>{e.style.transition="",this.transitionEndTrigger&&(this.transitionEndTrigger(),this.transitionEndTrigger=null)},this.touchstart=f=>{this.moving||(n.start(f),this.startDistance=this.getStartDistance(),this.transitionEndTrigger=null,this.moving=!0)},this.touchmove=f=>{n.move(f),n.isHorizontal()&&tt(f,!0),s(e,n.deltaX.value,"",0)},this.touchend=()=>{const f=n.deltaX.value;if(f==0)return;const d=n.duration.value;if(d<K&&Math.abs(f)>J){const _=et(f,d);s(e,_,"end",this.swipeDuration)}else s(e,f,"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 ot(t,e,n,s){return new nt(t,e,n,s)}const it=o.defineComponent({__name:"index",props:{activePath:null,routes:null,height:null,width:null,drag:{type:Boolean,default:!0},openViewPage:null,routerViewName:null,transition:{type:[Object,Boolean],default:!0},swipeDuration:{default:360},scrollTime:{default:0}},emits:["update:activePath"],setup(t,{emit:e}){const n=t,s=o.reactive({scrollDistance:0,index:-1,openedIndexList:[]}),h=ot(()=>s.scrollDistance,l=>{if(s.openedIndexList.indexOf(l)===-1){s.openedIndexList.push(l);const u=n.routes[l];try{n.openViewPage(u,l)}catch(p){console.error(p)}}},l=>s.openedIndexList.indexOf(l)!==-1,l=>{s.index=l,s.scrollDistance=-s.index*n.width;const u=n.routes[l];e("update:activePath",u.path)});o.onMounted(()=>{const l=g();h.el=l,h.open()}),o.onUnmounted(()=>{h.close()}),o.watchEffect(()=>{const l=n.activePath;s.index=n.routes.findIndex(y=>y.path===l);const u=n.width;s.index!==-1&&(s.openedIndexList.push(s.index),s.scrollDistance=-u*s.index);const p=u*n.routes.length,x=-u/3,w=u*(n.routes.length-1)+u/3;h.columnWidth=u,h.width=p,h.min=x,h.max=w,h.swipeDuration=n.swipeDuration});const c=`fox-swiper-navigator-${G()}`,i=o.computed(()=>({width:`${n.width}px`,height:`${n.height}px`}));let r=null;function g(){return r||(r=document.querySelector(`.${c}>.fox-swiper-navigator__inner`),r)}const a=o.computed(()=>`${n.width*n.routes.length}px`),v=(l,u)=>({style:{left:`${n.routes.findIndex(x=>{const w=l.path??l.name??"";return x.path==w})*n.width}px`,width:`${n.width}px`}});return(l,u)=>{const p=o.resolveComponent("fox-router-view");return o.openBlock(),o.createBlock(p,{class:o.normalizeClass(c),style:o.normalizeStyle(o.unref(i)),"view-class":"fox-swiper-navigator__item",tag:H,"view-tag-props":v,multi:!0,name:n.routerViewName,transition:n.transition,"scroll-distance":s.scrollDistance,"scroll-time":n.scrollTime,width:o.unref(a)},null,8,["style","name","transition","scroll-distance","scroll-time","width"])}}});const st=Object.freeze(Object.defineProperty({__proto__:null,default:it},Symbol.toStringTag,{value:"Module"}));let at="fox-";const rt=[],b=Object.assign({"/src/components/card-navigator/index.vue":P,"/src/components/default-navigator/index.vue":I,"/src/components/root-navigator/index.vue":Y,"/src/components/swiper-navigator/index.vue":st}),M=[];for(const t in b){let e=/src\/components\/(.*)\/index.vue/.exec(t)[1];rt.indexOf(e)===-1&&M.push({name:e,component:b[t].default})}const ct={install(t){M.forEach(e=>{t.component(`${at}${e.name}`,e.component)})}};module.exports=ct;
|
|
2
|
+
* @fox-js/navigation v4.0.1-6 Wed Jan 03 2024 16:14:47 GMT+0800 (中国标准时间)
|
|
3
|
+
*/const o=require("vue"),R=o.defineComponent({__name:"index",props:{routerViewName:null,transition:{type:[Object,Boolean],default:!1}},setup(t){const e=t;return(n,s)=>{const m=o.resolveComponent("fox-router-view");return o.openBlock(),o.createBlock(m,{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"])}}}),I=Object.freeze(Object.defineProperty({__proto__:null,default:R},Symbol.toStringTag,{value:"Module"})),S=o.defineComponent({__name:"index",props:{routerViewName:null,transition:{type:[Object,Boolean],default:!0}},setup(t){const e=t;return(n,s)=>{const m=o.resolveComponent("fox-router-view");return o.openBlock(),o.createBlock(m,{transition:!1,multi:!1,name:e.routerViewName},{default:o.withCtx(({Component:h})=>[o.createVNode(o.Transition,{name:"fox-default-navigator__trans"},{default:o.withCtx(()=>[(o.openBlock(),o.createBlock(o.resolveDynamicComponent(h)))]),_:2},1024)]),_:1},8,["name"])}}}),B=Object.freeze(Object.defineProperty({__proto__:null,default:S},Symbol.toStringTag,{value:"Module"})),$=10;function V(t,e){return t>e&&t>$?"horizontal":e>t&&e>$?"vertical":""}function O(){const t=o.ref(0),e=o.ref(0),n=o.ref(0),s=o.ref(0),m=o.ref(0),h=o.ref(0),g=o.ref(0),d=o.ref(0),u=o.ref(0),r=o.ref(0),i=o.ref(""),c=()=>i.value==="vertical",_=()=>i.value==="horizontal",f=()=>{g.value=0,d.value=0,u.value=0,r.value=0,i.value="",n.value=0};return{move:a=>{const p=a.touches[0];g.value=p.clientX-t.value,d.value=p.clientY-e.value,m.value=p.clientX,h.value=p.clientY,u.value=Math.abs(g.value),r.value=Math.abs(d.value),s.value=Date.now()-n.value,i.value||(i.value=V(u.value,r.value))},start:a=>{f(),t.value=a.touches[0].clientX,e.value=a.touches[0].clientY,n.value=Date.now()},reset:f,startX:t,startY:e,startTime:n,duration:s,moveX:m,moveY:h,deltaX:g,deltaY:d,offsetX:u,offsetY:r,direction:i,isVertical:c,isHorizontal:_}}function W(t){return t===window}const z=t=>{const e=o.unref(t);if(W(e)){const n=e.innerWidth,s=e.innerHeight;return{top:0,left:0,right:n,bottom:s,width:n,height:s}}return e&&e.getBoundingClientRect?e.getBoundingClientRect():{top:0,left:0,right:0,bottom:0,width:0,height:0}},N=15,k=300,j=200;function X(t){t.stopPropagation()}function A(t,e){(typeof t.cancelable!="boolean"||t.cancelable)&&t.preventDefault(),e&&X(t)}function U(t,e,n=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*n}function D(t,e=0,n,s=j){n==="end"?t.style.transition=`transform ${s}ms cubic-bezier(0.17, 0.89, 0.45, 1)`:t.style.transition="transform 0ms cubic-bezier(0.17, 0.89, 0.45, 1)",t.style.transform=`translate3d(${e}px, 0, 0)`}const E=new WeakMap;function Y(t,e,n,s,m=500,h,g=1e3){const d={active:!0,startDistance:0,scrollDistance:0,scrollTime:0,moving:!1,transitionEndTrigger:null},u=t.previousSibling,r=O(),i=(a,p,T,x)=>{let w=p+d.startDistance;if(T==="end"){const y=z(a);let C=y.width*e;w<C?w=0:w=y.width;let b=!1;x&&x>0&&(b=!0,d.transitionEndTrigger=()=>{d.moving=!1,h&&a.classList.remove(h),w>0&&typeof s=="function"&&s()}),D(a,w,"end",x),u&&D(u,0,"",0),!b&&w>0&&typeof s=="function"&&(d.moving=!1,s())}else w<0&&(w=0),D(a,w,"",0)},c=()=>{t.style.transform="",t.style.transition="",d.transitionEndTrigger?(d.transitionEndTrigger(),d.transitionEndTrigger=null,u&&setTimeout(()=>{u&&(u.style.transform="",u.style.transition="")},m)):u&&(u.style.transform="",u.style.transition="")},_=/^matrix\((.+)\)$/,f=a=>{if(r.start(a),d.scrollDistance=0,d.moving){const p=t,{transform:T}=window.getComputedStyle(p);if(T){const x=_.exec(T);if(x){const y=x[1].split(/,\s*/);d.scrollDistance=+y[4]}}}h&&t.classList.add(h),d.startDistance=d.scrollDistance,d.transitionEndTrigger=null,d.moving=!0},v=a=>{d.moving=!0,r.move(a),r.isHorizontal()&&A(a,!0),i(t,r.deltaX.value,"",0)},l=()=>{if(r.isVertical()){i(t,0,"end",g);return}const a=r.deltaX.value;if(a===0){h&&t.classList.remove(h),d.moving=!1;return}const p=r.duration.value;if(p<k&&Math.abs(a)>N){const x=U(a,p,n);i(t,x,"end",g)}else i(t,a,"end",g)};t.addEventListener("transitionend",c),t.addEventListener("touchstart",f),t.addEventListener("touchmove",v),t.addEventListener("touchend",l),t.addEventListener("touchcancel",l),E.set(t,{state:d,transitionend:c,touchstart:f,touchmove:v,touchend:l,touchcancel:l})}function q(t){const e=E.get(t);e&&(E.delete(t),t.addEventListener("transitionend",e.transitionend),t.addEventListener("touchstart",e.touchstart),t.addEventListener("touchmove",e.touchmove),t.addEventListener("touchend",e.touchend),t.addEventListener("touchcancel",e.touchcancel))}const H=o.defineComponent({__name:"index",props:{dragRemove:{type:Boolean,default:!0},removeViewPage:null,removeMoveRatio:{default:.5},momentumReduceRatio:{default:1},removeViewPageDuration:{default:500},routerViewName:null,viewTag:{default:"div"},transition:{type:[Object,Boolean],default:!0},viewClass:{default:"fox-root-navigator__item"}},setup(t){const e=t;function n(r){return(r.params&&r.params.animationType)??"slide"}const s=(r,i,c,_)=>{if(c.opsType===3||i){const f=n(c);if(f==="pop"&&i)return;const v=i?"show":"enter",l=`fox-root-navigator__${f}-${v}-from`,a=`fox-root-navigator__${f}-${v}-active`;r.classList.add(l),r.classList.add(a)}},m=(r,i,c,_)=>{if(c.opsType===3||i){const f=n(c);if(f==="pop"&&i)return;const v=i?"show":"enter",l=`fox-root-navigator__${f}-${v}-from`,a=`fox-root-navigator__${f}-${v}-to`;r.classList.remove(l),r.classList.add(a)}},h=(r,i,c,_)=>{if(c.opsType===3||i){const f=n(c);if(f!=="pop"||!i){const v=i?"show":"enter",l=`fox-root-navigator__${f}-${v}-active`,a=`fox-root-navigator__${f}-${v}-to`;r.classList.remove(l),r.classList.remove(a)}}e.dragRemove&&!i&&c.opsType===3&&Y(r,e.removeMoveRatio,e.momentumReduceRatio,e.removeViewPage,e.removeViewPageDuration,"fox-root-navigator__item-moving",1e3)},g=(r,i,c,_)=>{if(c.opsType===3||i){const f=n(c);if(f==="pop"&&i)return;const v=i?"hide":"leave",l=`fox-root-navigator__${f}-${v}-from`,a=`fox-root-navigator__${f}-${v}-active`;r.classList.add(l),r.classList.add(a)}},d=(r,i,c,_)=>{if(c.opsType===3||i){const f=n(c);if(f==="pop"&&i)return;const v=i?"hide":"leave",l=`fox-root-navigator__${f}-${v}-from`,a=`fox-root-navigator__${f}-${v}-to`;r.classList.remove(l),r.classList.add(a)}},u=(r,i,c,_)=>{if(c.opsType===3||i){const f=n(c);if(f!=="pop"||!i){const v=i?"hide":"leave",l=`fox-root-navigator__${f}-${v}-active`,a=`fox-root-navigator__${f}-${v}-to`;r.classList.remove(l),r.classList.remove(a)}}e.dragRemove&&!i&&q(r)};return(r,i)=>{const c=o.resolveComponent("fox-router-view");return o.openBlock(),o.createBlock(c,{class:"fox-root-navigator","view-class":t.viewClass,"before-enter":s,enter:m,"after-enter":h,"before-leave":g,leave:d,"after-leave":u,multi:!0,name:e.routerViewName,"view-tag":e.viewTag,transition:e.transition},null,8,["view-class","name","view-tag","transition"])}}}),F=Object.freeze(Object.defineProperty({__proto__:null,default:H},Symbol.toStringTag,{value:"Module"})),G={class:"fox-swiper-navigator"},J=o.defineComponent({__name:"swiper",props:{width:null,scrollDistance:null,scrollTime:null},setup(t){const e=t,n=o.computed(()=>({transform:`translate3d(${e.scrollDistance}px, 0, 0)`,width:`${e.width}`}));return(s,m)=>(o.openBlock(),o.createElementBlock("div",G,[o.createElementVNode("div",{class:"fox-swiper-navigator__inner",style:o.normalizeStyle(o.unref(n))},[o.renderSlot(s.$slots,"default")],4)]))}});let K=0;function Q(){return++K}const Z=15,tt=300,et=200;function nt(t){t.stopPropagation()}function ot(t,e){(typeof t.cancelable!="boolean"||t.cancelable)&&t.preventDefault(),e&&nt(t)}function it(t,e,n=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*n}function L(t,e=0,n,s=et){n==="end"?t.style.transition=`transform ${s}ms cubic-bezier(0.17, 0.89, 0.45, 1)`:t.style.transition="transform 0ms cubic-bezier(0.17, 0.89, 0.45, 1)",t.style.transform=`translate3d(${e}px, 0, 0)`}class st{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,s,m,h,g){this.getStartDistance=e,this.openPage=n,this.isPageOpened=s,this.pageOpened=m,this.moveRatio=h,this.momentumReduceRatio=g}open(){const e=this.el,n=O(),s=(m,h,g,d)=>{let u=h+this.startDistance;const r=this.columnWidth*this.moveRatio;if(g==="end"){if(u==0){this.moving=!1;return}Math.abs(h)>r&&(h>0?u=this.startDistance+this.columnWidth:u=this.startDistance-this.columnWidth);let i=-u;i<0?i=0:i>this.width-this.columnWidth&&(i=this.width-this.columnWidth);const c=Math.floor(i/this.columnWidth);this.isPageOpened(c)||this.openPage(c),u=-c*this.columnWidth,d&&d>0&&(this.transitionEndTrigger=()=>{this.moving=!1,this.pageOpened(c)}),L(m,u,"end",d),this.scrollDistance=u}else{if(Math.abs(h)>r){let c=0;if(h>0?c=Math.abs(this.startDistance+this.columnWidth):c=Math.abs(this.startDistance-this.columnWidth),c>=0&&c<this.width){const _=Math.floor(c/this.columnWidth);this.isPageOpened(_)||this.openPage(_)}}let i=-u;i<this.min?i=this.min:i>this.max&&(i=this.max),L(m,-i,"",0)}};this.transitionend=()=>{e.style.transition="",this.transitionEndTrigger&&(this.transitionEndTrigger(),this.transitionEndTrigger=null)},this.touchstart=m=>{this.moving||(n.start(m),this.startDistance=this.getStartDistance(),this.transitionEndTrigger=null,this.moving=!0)},this.touchmove=m=>{n.move(m),n.isHorizontal()&&ot(m,!0),s(e,n.deltaX.value,"",0)},this.touchend=()=>{if(n.isVertical()){s(e,0,"end",this.swipeDuration);return}const m=n.deltaX.value;if(m==0)return;const h=n.duration.value;if(h<tt&&Math.abs(m)>Z){const d=it(m,h,this.momentumReduceRatio);s(e,d,"end",this.swipeDuration)}else s(e,m,"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 at(t,e,n,s,m,h){return new st(t,e,n,s,m,h)}const rt=o.defineComponent({__name:"index",props:{activePath:null,routes:null,height:null,width:null,drag:{type:Boolean,default:!0},openViewPage:null,routerViewName:null,moveRatio:{default:.5},momentumReduceRatio:{default:1},transition:{type:[Object,Boolean],default:!0},swipeDuration:{default:360},scrollTime:{default:0}},emits:["update:activePath"],setup(t,{emit:e}){const n=t,s=o.reactive({scrollDistance:0,index:-1,openedIndexList:[]}),u=at(()=>s.scrollDistance,l=>{if(s.openedIndexList.indexOf(l)===-1){s.openedIndexList.push(l);const a=n.routes[l];try{n.openViewPage(a,l)}catch(p){console.error(p)}}},l=>s.openedIndexList.indexOf(l)!==-1,l=>{s.index=l,s.scrollDistance=-s.index*n.width;const a=n.routes[l];e("update:activePath",a.path)},n.moveRatio,n.momentumReduceRatio);o.onMounted(()=>{const l=_();u.el=l,u.open()}),o.onUnmounted(()=>{u.close()}),o.watchEffect(()=>{const l=n.activePath;s.index=n.routes.findIndex(w=>w.path===l);const a=n.width;s.index!==-1&&(s.openedIndexList.push(s.index),s.scrollDistance=-a*s.index);const p=a*n.routes.length,T=-a/3,x=a*(n.routes.length-1)+a/3;u.columnWidth=a,u.width=p,u.min=T,u.max=x,u.swipeDuration=n.swipeDuration});const r=`fox-swiper-navigator-${Q()}`,i=o.computed(()=>({width:`${n.width}px`,height:`${n.height}px`}));let c=null;function _(){return c||(c=document.querySelector(`.${r}>.fox-swiper-navigator__inner`),c)}const f=o.computed(()=>`${n.width*n.routes.length}px`),v=(l,a)=>({style:{left:`${n.routes.findIndex(T=>{const x=l.path??l.name??"";return T.path==x})*n.width}px`,width:`${n.width}px`}});return(l,a)=>{const p=o.resolveComponent("fox-router-view");return o.openBlock(),o.createBlock(p,{class:o.normalizeClass(r),style:o.normalizeStyle(o.unref(i)),"view-class":"fox-swiper-navigator__item",tag:J,"view-tag-props":v,multi:!0,name:n.routerViewName,transition:n.transition,"scroll-distance":s.scrollDistance,"scroll-time":n.scrollTime,width:o.unref(f)},null,8,["style","name","transition","scroll-distance","scroll-time","width"])}}}),ct=Object.freeze(Object.defineProperty({__proto__:null,default:rt},Symbol.toStringTag,{value:"Module"}));let lt="fox-";const ut=[],M=Object.assign({"/src/components/card-navigator/index.vue":I,"/src/components/default-navigator/index.vue":B,"/src/components/root-navigator/index.vue":F,"/src/components/swiper-navigator/index.vue":ct}),P=[];for(const t in M){let e=/src\/components\/(.*)\/index.vue/.exec(t)[1];ut.indexOf(e)===-1&&P.push({name:e,component:M[t].default})}const dt={install(t){P.forEach(e=>{t.component(`${lt}${e.name}`,e.component)})}};module.exports=dt;
|
package/dist/index.d.ts
CHANGED
package/dist/index.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as E, resolveComponent as L, openBlock as y, createBlock as D, withCtx as I, createVNode as B, Transition as X, resolveDynamicComponent as A, ref as w, unref as $, computed as O, createElementBlock as U, createElementVNode as Y, normalizeStyle as W, renderSlot as k, reactive as H, onMounted as q, onUnmounted as F, watchEffect as G, normalizeClass as J } from "vue";
|
|
2
2
|
/*!
|
|
3
|
-
* @fox-js/navigation v4.0.1-
|
|
3
|
+
* @fox-js/navigation v4.0.1-6 Wed Jan 03 2024 16:14:47 GMT+0800 (中国标准时间)
|
|
4
4
|
*/
|
|
5
|
-
const
|
|
5
|
+
const K = /* @__PURE__ */ E({
|
|
6
6
|
__name: "index",
|
|
7
7
|
props: {
|
|
8
8
|
routerViewName: null,
|
|
@@ -11,8 +11,8 @@ const F = /* @__PURE__ */ D({
|
|
|
11
11
|
setup(t) {
|
|
12
12
|
const e = t;
|
|
13
13
|
return (n, i) => {
|
|
14
|
-
const
|
|
15
|
-
return
|
|
14
|
+
const f = L("fox-router-view");
|
|
15
|
+
return y(), D(f, {
|
|
16
16
|
class: "fox-card-navigator",
|
|
17
17
|
"view-class": "fox-card-navigator__item",
|
|
18
18
|
"view-active-class": "fox-card-navigator__item-active",
|
|
@@ -24,11 +24,10 @@ const F = /* @__PURE__ */ D({
|
|
|
24
24
|
}, null, 8, ["transition", "name"]);
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
})
|
|
28
|
-
const G = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
27
|
+
}), Q = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
29
28
|
__proto__: null,
|
|
30
|
-
default:
|
|
31
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
29
|
+
default: K
|
|
30
|
+
}, Symbol.toStringTag, { value: "Module" })), Z = /* @__PURE__ */ E({
|
|
32
31
|
__name: "index",
|
|
33
32
|
props: {
|
|
34
33
|
routerViewName: null,
|
|
@@ -37,16 +36,16 @@ const G = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
37
36
|
setup(t) {
|
|
38
37
|
const e = t;
|
|
39
38
|
return (n, i) => {
|
|
40
|
-
const
|
|
41
|
-
return
|
|
39
|
+
const f = L("fox-router-view");
|
|
40
|
+
return y(), D(f, {
|
|
42
41
|
transition: !1,
|
|
43
42
|
multi: !1,
|
|
44
43
|
name: e.routerViewName
|
|
45
44
|
}, {
|
|
46
|
-
default:
|
|
47
|
-
|
|
48
|
-
default:
|
|
49
|
-
(
|
|
45
|
+
default: I(({ Component: h }) => [
|
|
46
|
+
B(X, { name: "fox-default-navigator__trans" }, {
|
|
47
|
+
default: I(() => [
|
|
48
|
+
(y(), D(A(h)))
|
|
50
49
|
]),
|
|
51
50
|
_: 2
|
|
52
51
|
}, 1024)
|
|
@@ -55,48 +54,47 @@ const G = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
55
54
|
}, 8, ["name"]);
|
|
56
55
|
};
|
|
57
56
|
}
|
|
58
|
-
})
|
|
59
|
-
const K = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
57
|
+
}), tt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
60
58
|
__proto__: null,
|
|
61
|
-
default:
|
|
62
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
63
|
-
function
|
|
64
|
-
return t > e && t >
|
|
59
|
+
default: Z
|
|
60
|
+
}, Symbol.toStringTag, { value: "Module" })), S = 10;
|
|
61
|
+
function et(t, e) {
|
|
62
|
+
return t > e && t > S ? "horizontal" : e > t && e > S ? "vertical" : "";
|
|
65
63
|
}
|
|
66
|
-
function
|
|
67
|
-
const t =
|
|
68
|
-
|
|
64
|
+
function N() {
|
|
65
|
+
const t = w(0), e = w(0), n = w(0), i = w(0), f = w(0), h = w(0), p = w(0), u = w(0), l = w(0), a = w(0), o = w(""), r = () => o.value === "vertical", g = () => o.value === "horizontal", d = () => {
|
|
66
|
+
p.value = 0, u.value = 0, l.value = 0, a.value = 0, o.value = "", n.value = 0;
|
|
69
67
|
};
|
|
70
68
|
return {
|
|
71
|
-
move: (
|
|
72
|
-
const v =
|
|
73
|
-
|
|
69
|
+
move: (s) => {
|
|
70
|
+
const v = s.touches[0];
|
|
71
|
+
p.value = v.clientX - t.value, u.value = v.clientY - e.value, f.value = v.clientX, h.value = v.clientY, l.value = Math.abs(p.value), a.value = Math.abs(u.value), i.value = Date.now() - n.value, o.value || (o.value = et(l.value, a.value));
|
|
74
72
|
},
|
|
75
|
-
start: (
|
|
76
|
-
|
|
73
|
+
start: (s) => {
|
|
74
|
+
d(), t.value = s.touches[0].clientX, e.value = s.touches[0].clientY, n.value = Date.now();
|
|
77
75
|
},
|
|
78
|
-
reset:
|
|
76
|
+
reset: d,
|
|
79
77
|
startX: t,
|
|
80
78
|
startY: e,
|
|
81
79
|
startTime: n,
|
|
82
80
|
duration: i,
|
|
83
|
-
moveX:
|
|
84
|
-
moveY:
|
|
85
|
-
deltaX:
|
|
86
|
-
deltaY:
|
|
87
|
-
offsetX:
|
|
88
|
-
offsetY:
|
|
81
|
+
moveX: f,
|
|
82
|
+
moveY: h,
|
|
83
|
+
deltaX: p,
|
|
84
|
+
deltaY: u,
|
|
85
|
+
offsetX: l,
|
|
86
|
+
offsetY: a,
|
|
89
87
|
direction: o,
|
|
90
|
-
isVertical:
|
|
91
|
-
isHorizontal:
|
|
88
|
+
isVertical: r,
|
|
89
|
+
isHorizontal: g
|
|
92
90
|
};
|
|
93
91
|
}
|
|
94
|
-
function
|
|
92
|
+
function nt(t) {
|
|
95
93
|
return t === window;
|
|
96
94
|
}
|
|
97
|
-
const
|
|
98
|
-
const e =
|
|
99
|
-
if (
|
|
95
|
+
const ot = (t) => {
|
|
96
|
+
const e = $(t);
|
|
97
|
+
if (nt(e)) {
|
|
100
98
|
const n = e.innerWidth, i = e.innerHeight;
|
|
101
99
|
return {
|
|
102
100
|
top: 0,
|
|
@@ -115,21 +113,21 @@ const tt = (t) => {
|
|
|
115
113
|
width: 0,
|
|
116
114
|
height: 0
|
|
117
115
|
};
|
|
118
|
-
},
|
|
119
|
-
function
|
|
116
|
+
}, it = 15, st = 300, at = 200;
|
|
117
|
+
function rt(t) {
|
|
120
118
|
t.stopPropagation();
|
|
121
119
|
}
|
|
122
|
-
function
|
|
123
|
-
(typeof t.cancelable != "boolean" || t.cancelable) && t.preventDefault(), e &&
|
|
120
|
+
function ct(t, e) {
|
|
121
|
+
(typeof t.cancelable != "boolean" || t.cancelable) && t.preventDefault(), e && rt(t);
|
|
124
122
|
}
|
|
125
|
-
function
|
|
126
|
-
return t = Math.abs(t / e) / 3e-3 * (t < 0 ? -1 : 1), t;
|
|
123
|
+
function lt(t, e, n = 1) {
|
|
124
|
+
return t = Math.abs(t / e) / 3e-3 * (t < 0 ? -1 : 1), t * n;
|
|
127
125
|
}
|
|
128
|
-
function
|
|
126
|
+
function M(t, e = 0, n, i = at) {
|
|
129
127
|
n === "end" ? t.style.transition = `transform ${i}ms cubic-bezier(0.17, 0.89, 0.45, 1)` : t.style.transition = "transform 0ms cubic-bezier(0.17, 0.89, 0.45, 1)", t.style.transform = `translate3d(${e}px, 0, 0)`;
|
|
130
128
|
}
|
|
131
|
-
const
|
|
132
|
-
function
|
|
129
|
+
const P = /* @__PURE__ */ new WeakMap();
|
|
130
|
+
function ut(t, e, n, i, f = 500, h, p = 1e3) {
|
|
133
131
|
const u = {
|
|
134
132
|
active: !0,
|
|
135
133
|
startDistance: 0,
|
|
@@ -137,61 +135,73 @@ function rt(t, e, n = 500, i, d = 1e3) {
|
|
|
137
135
|
scrollTime: 0,
|
|
138
136
|
moving: !1,
|
|
139
137
|
transitionEndTrigger: null
|
|
140
|
-
},
|
|
141
|
-
let
|
|
142
|
-
if (
|
|
143
|
-
const
|
|
144
|
-
let
|
|
145
|
-
|
|
146
|
-
let
|
|
147
|
-
|
|
148
|
-
u.moving = !1,
|
|
149
|
-
}),
|
|
138
|
+
}, l = t.previousSibling, a = N(), o = (s, v, T, _) => {
|
|
139
|
+
let x = v + u.startDistance;
|
|
140
|
+
if (T === "end") {
|
|
141
|
+
const b = ot(s);
|
|
142
|
+
let j = b.width * e;
|
|
143
|
+
x < j ? x = 0 : x = b.width;
|
|
144
|
+
let R = !1;
|
|
145
|
+
_ && _ > 0 && (R = !0, u.transitionEndTrigger = () => {
|
|
146
|
+
u.moving = !1, h && s.classList.remove(h), x > 0 && typeof i == "function" && i();
|
|
147
|
+
}), M(s, x, "end", _), l && M(l, 0, "", 0), !R && x > 0 && typeof i == "function" && (u.moving = !1, i());
|
|
150
148
|
} else
|
|
151
|
-
|
|
149
|
+
x < 0 && (x = 0), M(s, x, "", 0);
|
|
152
150
|
}, r = () => {
|
|
153
|
-
t.style.transform = "", t.style.transition = "", u.transitionEndTrigger ? (u.transitionEndTrigger(), u.transitionEndTrigger = null,
|
|
154
|
-
|
|
155
|
-
},
|
|
156
|
-
},
|
|
157
|
-
if (
|
|
158
|
-
const
|
|
159
|
-
|
|
151
|
+
t.style.transform = "", t.style.transition = "", u.transitionEndTrigger ? (u.transitionEndTrigger(), u.transitionEndTrigger = null, l && setTimeout(() => {
|
|
152
|
+
l && (l.style.transform = "", l.style.transition = "");
|
|
153
|
+
}, f)) : l && (l.style.transform = "", l.style.transition = "");
|
|
154
|
+
}, g = /^matrix\((.+)\)$/, d = (s) => {
|
|
155
|
+
if (a.start(s), u.scrollDistance = 0, u.moving) {
|
|
156
|
+
const v = t, { transform: T } = window.getComputedStyle(v);
|
|
157
|
+
if (T) {
|
|
158
|
+
const _ = g.exec(T);
|
|
159
|
+
if (_) {
|
|
160
|
+
const b = _[1].split(/,\s*/);
|
|
161
|
+
u.scrollDistance = +b[4];
|
|
162
|
+
}
|
|
163
|
+
}
|
|
160
164
|
}
|
|
161
|
-
|
|
162
|
-
},
|
|
163
|
-
u.moving = !0,
|
|
164
|
-
},
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
i && t.classList.remove(i);
|
|
165
|
+
h && t.classList.add(h), u.startDistance = u.scrollDistance, u.transitionEndTrigger = null, u.moving = !0;
|
|
166
|
+
}, m = (s) => {
|
|
167
|
+
u.moving = !0, a.move(s), a.isHorizontal() && ct(s, !0), o(t, a.deltaX.value, "", 0);
|
|
168
|
+
}, c = () => {
|
|
169
|
+
if (a.isVertical()) {
|
|
170
|
+
o(t, 0, "end", p);
|
|
168
171
|
return;
|
|
169
172
|
}
|
|
170
|
-
const
|
|
171
|
-
if (
|
|
172
|
-
|
|
173
|
-
|
|
173
|
+
const s = a.deltaX.value;
|
|
174
|
+
if (s === 0) {
|
|
175
|
+
h && t.classList.remove(h), u.moving = !1;
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
const v = a.duration.value;
|
|
179
|
+
if (v < st && Math.abs(s) > it) {
|
|
180
|
+
const _ = lt(s, v, n);
|
|
181
|
+
o(t, _, "end", p);
|
|
174
182
|
} else
|
|
175
|
-
|
|
183
|
+
o(t, s, "end", p);
|
|
176
184
|
};
|
|
177
|
-
t.addEventListener("transitionend", r), t.addEventListener("touchstart",
|
|
185
|
+
t.addEventListener("transitionend", r), t.addEventListener("touchstart", d), t.addEventListener("touchmove", m), t.addEventListener("touchend", c), t.addEventListener("touchcancel", c), P.set(t, {
|
|
178
186
|
state: u,
|
|
179
187
|
transitionend: r,
|
|
180
|
-
touchstart:
|
|
181
|
-
touchmove:
|
|
182
|
-
touchend:
|
|
183
|
-
touchcancel:
|
|
188
|
+
touchstart: d,
|
|
189
|
+
touchmove: m,
|
|
190
|
+
touchend: c,
|
|
191
|
+
touchcancel: c
|
|
184
192
|
});
|
|
185
193
|
}
|
|
186
|
-
function
|
|
187
|
-
const e =
|
|
188
|
-
e && (
|
|
194
|
+
function dt(t) {
|
|
195
|
+
const e = P.get(t);
|
|
196
|
+
e && (P.delete(t), t.addEventListener("transitionend", e.transitionend), t.addEventListener("touchstart", e.touchstart), t.addEventListener("touchmove", e.touchmove), t.addEventListener("touchend", e.touchend), t.addEventListener("touchcancel", e.touchcancel));
|
|
189
197
|
}
|
|
190
|
-
const
|
|
198
|
+
const ft = /* @__PURE__ */ E({
|
|
191
199
|
__name: "index",
|
|
192
200
|
props: {
|
|
193
201
|
dragRemove: { type: Boolean, default: !0 },
|
|
194
202
|
removeViewPage: null,
|
|
203
|
+
removeMoveRatio: { default: 0.5 },
|
|
204
|
+
momentumReduceRatio: { default: 1 },
|
|
195
205
|
removeViewPageDuration: { default: 500 },
|
|
196
206
|
routerViewName: null,
|
|
197
207
|
viewTag: { default: "div" },
|
|
@@ -200,71 +210,79 @@ const lt = /* @__PURE__ */ D({
|
|
|
200
210
|
},
|
|
201
211
|
setup(t) {
|
|
202
212
|
const e = t;
|
|
203
|
-
function n(
|
|
204
|
-
return (
|
|
213
|
+
function n(a) {
|
|
214
|
+
return (a.params && a.params.animationType) ?? "slide";
|
|
205
215
|
}
|
|
206
|
-
const i = (
|
|
207
|
-
if (
|
|
208
|
-
const
|
|
209
|
-
if (
|
|
216
|
+
const i = (a, o, r, g) => {
|
|
217
|
+
if (r.opsType === 3 || o) {
|
|
218
|
+
const d = n(r);
|
|
219
|
+
if (d === "pop" && o)
|
|
210
220
|
return;
|
|
211
|
-
const
|
|
212
|
-
|
|
221
|
+
const m = o ? "show" : "enter", c = `fox-root-navigator__${d}-${m}-from`, s = `fox-root-navigator__${d}-${m}-active`;
|
|
222
|
+
a.classList.add(c), a.classList.add(s);
|
|
213
223
|
}
|
|
214
|
-
},
|
|
215
|
-
if (
|
|
216
|
-
const
|
|
217
|
-
if (
|
|
224
|
+
}, f = (a, o, r, g) => {
|
|
225
|
+
if (r.opsType === 3 || o) {
|
|
226
|
+
const d = n(r);
|
|
227
|
+
if (d === "pop" && o)
|
|
218
228
|
return;
|
|
219
|
-
const
|
|
220
|
-
|
|
229
|
+
const m = o ? "show" : "enter", c = `fox-root-navigator__${d}-${m}-from`, s = `fox-root-navigator__${d}-${m}-to`;
|
|
230
|
+
a.classList.remove(c), a.classList.add(s);
|
|
221
231
|
}
|
|
222
|
-
},
|
|
223
|
-
if (
|
|
224
|
-
const
|
|
225
|
-
if (
|
|
226
|
-
const
|
|
227
|
-
|
|
232
|
+
}, h = (a, o, r, g) => {
|
|
233
|
+
if (r.opsType === 3 || o) {
|
|
234
|
+
const d = n(r);
|
|
235
|
+
if (d !== "pop" || !o) {
|
|
236
|
+
const m = o ? "show" : "enter", c = `fox-root-navigator__${d}-${m}-active`, s = `fox-root-navigator__${d}-${m}-to`;
|
|
237
|
+
a.classList.remove(c), a.classList.remove(s);
|
|
228
238
|
}
|
|
229
239
|
}
|
|
230
|
-
e.dragRemove && !o &&
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
240
|
+
e.dragRemove && !o && r.opsType === 3 && ut(
|
|
241
|
+
a,
|
|
242
|
+
e.removeMoveRatio,
|
|
243
|
+
e.momentumReduceRatio,
|
|
244
|
+
e.removeViewPage,
|
|
245
|
+
e.removeViewPageDuration,
|
|
246
|
+
"fox-root-navigator__item-moving",
|
|
247
|
+
1e3
|
|
248
|
+
);
|
|
249
|
+
}, p = (a, o, r, g) => {
|
|
250
|
+
if (r.opsType === 3 || o) {
|
|
251
|
+
const d = n(r);
|
|
252
|
+
if (d === "pop" && o)
|
|
235
253
|
return;
|
|
236
|
-
const
|
|
237
|
-
|
|
254
|
+
const m = o ? "hide" : "leave", c = `fox-root-navigator__${d}-${m}-from`, s = `fox-root-navigator__${d}-${m}-active`;
|
|
255
|
+
a.classList.add(c), a.classList.add(s);
|
|
238
256
|
}
|
|
239
|
-
},
|
|
240
|
-
if (
|
|
241
|
-
const
|
|
242
|
-
if (
|
|
257
|
+
}, u = (a, o, r, g) => {
|
|
258
|
+
if (r.opsType === 3 || o) {
|
|
259
|
+
const d = n(r);
|
|
260
|
+
if (d === "pop" && o)
|
|
243
261
|
return;
|
|
244
|
-
const
|
|
245
|
-
|
|
262
|
+
const m = o ? "hide" : "leave", c = `fox-root-navigator__${d}-${m}-from`, s = `fox-root-navigator__${d}-${m}-to`;
|
|
263
|
+
a.classList.remove(c), a.classList.add(s);
|
|
246
264
|
}
|
|
247
|
-
},
|
|
248
|
-
if (
|
|
249
|
-
const
|
|
250
|
-
if (
|
|
251
|
-
const
|
|
252
|
-
|
|
265
|
+
}, l = (a, o, r, g) => {
|
|
266
|
+
if (r.opsType === 3 || o) {
|
|
267
|
+
const d = n(r);
|
|
268
|
+
if (d !== "pop" || !o) {
|
|
269
|
+
const m = o ? "hide" : "leave", c = `fox-root-navigator__${d}-${m}-active`, s = `fox-root-navigator__${d}-${m}-to`;
|
|
270
|
+
a.classList.remove(c), a.classList.remove(s);
|
|
253
271
|
}
|
|
254
272
|
}
|
|
255
|
-
e.dragRemove && !o &&
|
|
273
|
+
e.dragRemove && !o && dt(a);
|
|
256
274
|
};
|
|
257
|
-
return (
|
|
258
|
-
const
|
|
259
|
-
return
|
|
275
|
+
return (a, o) => {
|
|
276
|
+
const r = L("fox-router-view");
|
|
277
|
+
return y(), D(r, {
|
|
260
278
|
class: "fox-root-navigator",
|
|
261
279
|
"view-class": t.viewClass,
|
|
262
280
|
"before-enter": i,
|
|
263
|
-
enter:
|
|
264
|
-
"after-enter":
|
|
265
|
-
"before-leave":
|
|
266
|
-
leave:
|
|
267
|
-
"after-leave":
|
|
281
|
+
enter: f,
|
|
282
|
+
"after-enter": h,
|
|
283
|
+
"before-leave": p,
|
|
284
|
+
leave: u,
|
|
285
|
+
"after-leave": l,
|
|
268
286
|
multi: !0,
|
|
269
287
|
name: e.routerViewName,
|
|
270
288
|
"view-tag": e.viewTag,
|
|
@@ -272,11 +290,10 @@ const lt = /* @__PURE__ */ D({
|
|
|
272
290
|
}, null, 8, ["view-class", "name", "view-tag", "transition"]);
|
|
273
291
|
};
|
|
274
292
|
}
|
|
275
|
-
})
|
|
276
|
-
const ut = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
293
|
+
}), ht = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
277
294
|
__proto__: null,
|
|
278
|
-
default:
|
|
279
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
295
|
+
default: ft
|
|
296
|
+
}, Symbol.toStringTag, { value: "Module" })), mt = { class: "fox-swiper-navigator" }, vt = /* @__PURE__ */ E({
|
|
280
297
|
__name: "swiper",
|
|
281
298
|
props: {
|
|
282
299
|
width: null,
|
|
@@ -284,115 +301,201 @@ const ut = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
284
301
|
scrollTime: null
|
|
285
302
|
},
|
|
286
303
|
setup(t) {
|
|
287
|
-
const e = t, n =
|
|
304
|
+
const e = t, n = O(() => ({
|
|
305
|
+
// transition: `transform ${props.scrollTime}ms cubic-bezier(0.17, 0.89, 0.45, 1)`,
|
|
288
306
|
transform: `translate3d(${e.scrollDistance}px, 0, 0)`,
|
|
289
307
|
width: `${e.width}`
|
|
290
308
|
}));
|
|
291
|
-
return (i,
|
|
292
|
-
|
|
309
|
+
return (i, f) => (y(), U("div", mt, [
|
|
310
|
+
Y("div", {
|
|
293
311
|
class: "fox-swiper-navigator__inner",
|
|
294
|
-
style:
|
|
312
|
+
style: W($(n))
|
|
295
313
|
}, [
|
|
296
|
-
|
|
314
|
+
k(i.$slots, "default")
|
|
297
315
|
], 4)
|
|
298
316
|
]));
|
|
299
317
|
}
|
|
300
318
|
});
|
|
301
|
-
let
|
|
302
|
-
function
|
|
303
|
-
return ++
|
|
319
|
+
let pt = 0;
|
|
320
|
+
function gt() {
|
|
321
|
+
return ++pt;
|
|
304
322
|
}
|
|
305
|
-
const
|
|
306
|
-
function
|
|
323
|
+
const _t = 15, xt = 300, wt = 200;
|
|
324
|
+
function Tt(t) {
|
|
307
325
|
t.stopPropagation();
|
|
308
326
|
}
|
|
309
|
-
function
|
|
310
|
-
(typeof t.cancelable != "boolean" || t.cancelable) && t.preventDefault(), e &&
|
|
327
|
+
function yt(t, e) {
|
|
328
|
+
(typeof t.cancelable != "boolean" || t.cancelable) && t.preventDefault(), e && Tt(t);
|
|
311
329
|
}
|
|
312
|
-
function
|
|
313
|
-
return t = Math.abs(t / e) / 3e-3 * (t < 0 ? -1 : 1), t;
|
|
330
|
+
function Dt(t, e, n = 1) {
|
|
331
|
+
return t = Math.abs(t / e) / 3e-3 * (t < 0 ? -1 : 1), t * n;
|
|
314
332
|
}
|
|
315
|
-
function
|
|
333
|
+
function C(t, e = 0, n, i = wt) {
|
|
316
334
|
n === "end" ? t.style.transition = `transform ${i}ms cubic-bezier(0.17, 0.89, 0.45, 1)` : t.style.transition = "transform 0ms cubic-bezier(0.17, 0.89, 0.45, 1)", t.style.transform = `translate3d(${e}px, 0, 0)`;
|
|
317
335
|
}
|
|
318
|
-
class
|
|
336
|
+
class Et {
|
|
337
|
+
/**
|
|
338
|
+
* width
|
|
339
|
+
*/
|
|
319
340
|
width = 0;
|
|
341
|
+
/**
|
|
342
|
+
* column width
|
|
343
|
+
*/
|
|
320
344
|
columnWidth = 0;
|
|
345
|
+
/**
|
|
346
|
+
* max
|
|
347
|
+
*/
|
|
321
348
|
max = 0;
|
|
349
|
+
/**
|
|
350
|
+
* min
|
|
351
|
+
*/
|
|
322
352
|
min = 0;
|
|
353
|
+
/**
|
|
354
|
+
* element
|
|
355
|
+
*/
|
|
323
356
|
el = null;
|
|
357
|
+
/**
|
|
358
|
+
* swipe duration
|
|
359
|
+
*/
|
|
324
360
|
swipeDuration = 360;
|
|
361
|
+
/**
|
|
362
|
+
* transitionEndTrigger
|
|
363
|
+
*/
|
|
325
364
|
transitionEndTrigger = null;
|
|
365
|
+
/**
|
|
366
|
+
* moving
|
|
367
|
+
*/
|
|
326
368
|
moving = !1;
|
|
369
|
+
/**
|
|
370
|
+
* start distance
|
|
371
|
+
*/
|
|
327
372
|
startDistance = 0;
|
|
373
|
+
/**
|
|
374
|
+
* scroll distance
|
|
375
|
+
*/
|
|
328
376
|
scrollDistance = 0;
|
|
377
|
+
/**
|
|
378
|
+
* 获取start distance
|
|
379
|
+
*/
|
|
329
380
|
getStartDistance;
|
|
381
|
+
/**
|
|
382
|
+
* open page
|
|
383
|
+
*/
|
|
330
384
|
openPage;
|
|
385
|
+
/**
|
|
386
|
+
* is page opened
|
|
387
|
+
*/
|
|
331
388
|
isPageOpened;
|
|
389
|
+
/**
|
|
390
|
+
* page opened
|
|
391
|
+
*/
|
|
332
392
|
pageOpened;
|
|
393
|
+
/**
|
|
394
|
+
*触发移动页面的移动比例(相对页面)
|
|
395
|
+
*/
|
|
396
|
+
moveRatio = 0.5;
|
|
397
|
+
/**
|
|
398
|
+
* 惯性削减比例
|
|
399
|
+
*/
|
|
400
|
+
momentumReduceRatio = 1;
|
|
401
|
+
/**
|
|
402
|
+
* transitionend
|
|
403
|
+
*/
|
|
333
404
|
transitionend = null;
|
|
405
|
+
/**
|
|
406
|
+
* touchstart
|
|
407
|
+
*/
|
|
334
408
|
touchstart = null;
|
|
409
|
+
/**
|
|
410
|
+
* touchmove
|
|
411
|
+
*/
|
|
335
412
|
touchmove = null;
|
|
413
|
+
/**
|
|
414
|
+
* touchend
|
|
415
|
+
*/
|
|
336
416
|
touchend = null;
|
|
417
|
+
/**
|
|
418
|
+
* touchcancel
|
|
419
|
+
*/
|
|
337
420
|
touchcancel = null;
|
|
338
|
-
|
|
339
|
-
|
|
421
|
+
/**
|
|
422
|
+
* 构造函数
|
|
423
|
+
* @param getStartDistance
|
|
424
|
+
* @param openPage
|
|
425
|
+
* @param isPageOpened
|
|
426
|
+
* @param pageOpened
|
|
427
|
+
* @param moveRatio
|
|
428
|
+
* @param momentumReduceRatio
|
|
429
|
+
*
|
|
430
|
+
*/
|
|
431
|
+
constructor(e, n, i, f, h, p) {
|
|
432
|
+
this.getStartDistance = e, this.openPage = n, this.isPageOpened = i, this.pageOpened = f, this.moveRatio = h, this.momentumReduceRatio = p;
|
|
340
433
|
}
|
|
434
|
+
/**
|
|
435
|
+
* 打开drag支持
|
|
436
|
+
*/
|
|
341
437
|
open() {
|
|
342
|
-
const e = this.el, n =
|
|
343
|
-
let
|
|
344
|
-
const
|
|
345
|
-
if (
|
|
346
|
-
if (
|
|
438
|
+
const e = this.el, n = N(), i = (f, h, p, u) => {
|
|
439
|
+
let l = h + this.startDistance;
|
|
440
|
+
const a = this.columnWidth * this.moveRatio;
|
|
441
|
+
if (p === "end") {
|
|
442
|
+
if (l == 0) {
|
|
347
443
|
this.moving = !1;
|
|
348
444
|
return;
|
|
349
445
|
}
|
|
350
|
-
Math.abs(
|
|
351
|
-
let o = -
|
|
446
|
+
Math.abs(h) > a && (h > 0 ? l = this.startDistance + this.columnWidth : l = this.startDistance - this.columnWidth);
|
|
447
|
+
let o = -l;
|
|
352
448
|
o < 0 ? o = 0 : o > this.width - this.columnWidth && (o = this.width - this.columnWidth);
|
|
353
|
-
const
|
|
354
|
-
this.isPageOpened(
|
|
355
|
-
this.moving = !1, this.pageOpened(
|
|
356
|
-
}),
|
|
449
|
+
const r = Math.floor(o / this.columnWidth);
|
|
450
|
+
this.isPageOpened(r) || this.openPage(r), l = -r * this.columnWidth, u && u > 0 && (this.transitionEndTrigger = () => {
|
|
451
|
+
this.moving = !1, this.pageOpened(r);
|
|
452
|
+
}), C(f, l, "end", u), this.scrollDistance = l;
|
|
357
453
|
} else {
|
|
358
|
-
if (Math.abs(
|
|
359
|
-
let
|
|
360
|
-
if (
|
|
361
|
-
const
|
|
362
|
-
this.isPageOpened(
|
|
454
|
+
if (Math.abs(h) > a) {
|
|
455
|
+
let r = 0;
|
|
456
|
+
if (h > 0 ? r = Math.abs(this.startDistance + this.columnWidth) : r = Math.abs(this.startDistance - this.columnWidth), r >= 0 && r < this.width) {
|
|
457
|
+
const g = Math.floor(r / this.columnWidth);
|
|
458
|
+
this.isPageOpened(g) || this.openPage(g);
|
|
363
459
|
}
|
|
364
460
|
}
|
|
365
|
-
let o = -
|
|
366
|
-
o < this.min ? o = this.min : o > this.max && (o = this.max),
|
|
461
|
+
let o = -l;
|
|
462
|
+
o < this.min ? o = this.min : o > this.max && (o = this.max), C(f, -o, "", 0);
|
|
367
463
|
}
|
|
368
464
|
};
|
|
369
465
|
this.transitionend = () => {
|
|
370
466
|
e.style.transition = "", this.transitionEndTrigger && (this.transitionEndTrigger(), this.transitionEndTrigger = null);
|
|
371
|
-
}, this.touchstart = (
|
|
372
|
-
this.moving || (n.start(
|
|
373
|
-
}, this.touchmove = (
|
|
374
|
-
n.move(
|
|
467
|
+
}, this.touchstart = (f) => {
|
|
468
|
+
this.moving || (n.start(f), this.startDistance = this.getStartDistance(), this.transitionEndTrigger = null, this.moving = !0);
|
|
469
|
+
}, this.touchmove = (f) => {
|
|
470
|
+
n.move(f), n.isHorizontal() && yt(f, !0), i(e, n.deltaX.value, "", 0);
|
|
375
471
|
}, this.touchend = () => {
|
|
376
|
-
|
|
377
|
-
|
|
472
|
+
if (n.isVertical()) {
|
|
473
|
+
i(e, 0, "end", this.swipeDuration);
|
|
378
474
|
return;
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
475
|
+
}
|
|
476
|
+
const f = n.deltaX.value;
|
|
477
|
+
if (f == 0)
|
|
478
|
+
return;
|
|
479
|
+
const h = n.duration.value;
|
|
480
|
+
if (h < xt && Math.abs(f) > _t) {
|
|
481
|
+
const u = Dt(f, h, this.momentumReduceRatio);
|
|
482
|
+
i(e, u, "end", this.swipeDuration);
|
|
383
483
|
} else
|
|
384
|
-
i(e,
|
|
484
|
+
i(e, f, "end", this.swipeDuration);
|
|
385
485
|
}, 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);
|
|
386
486
|
}
|
|
487
|
+
/**
|
|
488
|
+
* 关闭drag支持
|
|
489
|
+
*/
|
|
387
490
|
close() {
|
|
388
491
|
const e = this.el;
|
|
389
492
|
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;
|
|
390
493
|
}
|
|
391
494
|
}
|
|
392
|
-
function
|
|
393
|
-
return new
|
|
495
|
+
function bt(t, e, n, i, f, h) {
|
|
496
|
+
return new Et(t, e, n, i, f, h);
|
|
394
497
|
}
|
|
395
|
-
const
|
|
498
|
+
const $t = /* @__PURE__ */ E({
|
|
396
499
|
__name: "index",
|
|
397
500
|
props: {
|
|
398
501
|
activePath: null,
|
|
@@ -402,96 +505,108 @@ const Dt = /* @__PURE__ */ D({
|
|
|
402
505
|
drag: { type: Boolean, default: !0 },
|
|
403
506
|
openViewPage: null,
|
|
404
507
|
routerViewName: null,
|
|
508
|
+
moveRatio: { default: 0.5 },
|
|
509
|
+
momentumReduceRatio: { default: 1 },
|
|
405
510
|
transition: { type: [Object, Boolean], default: !0 },
|
|
406
511
|
swipeDuration: { default: 360 },
|
|
407
512
|
scrollTime: { default: 0 }
|
|
408
513
|
},
|
|
409
514
|
emits: ["update:activePath"],
|
|
410
515
|
setup(t, { emit: e }) {
|
|
411
|
-
const n = t, i =
|
|
516
|
+
const n = t, i = H({
|
|
412
517
|
scrollDistance: 0,
|
|
413
518
|
index: -1,
|
|
414
519
|
openedIndexList: []
|
|
415
|
-
}),
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
n.
|
|
421
|
-
|
|
422
|
-
|
|
520
|
+
}), l = bt(
|
|
521
|
+
() => i.scrollDistance,
|
|
522
|
+
(c) => {
|
|
523
|
+
if (i.openedIndexList.indexOf(c) === -1) {
|
|
524
|
+
i.openedIndexList.push(c);
|
|
525
|
+
const s = n.routes[c];
|
|
526
|
+
try {
|
|
527
|
+
n.openViewPage(s, c);
|
|
528
|
+
} catch (v) {
|
|
529
|
+
console.error(v);
|
|
530
|
+
}
|
|
423
531
|
}
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
532
|
+
},
|
|
533
|
+
(c) => i.openedIndexList.indexOf(c) !== -1,
|
|
534
|
+
(c) => {
|
|
535
|
+
i.index = c, i.scrollDistance = -i.index * n.width;
|
|
536
|
+
const s = n.routes[c];
|
|
537
|
+
e("update:activePath", s.path);
|
|
538
|
+
},
|
|
539
|
+
n.moveRatio,
|
|
540
|
+
n.momentumReduceRatio
|
|
541
|
+
);
|
|
542
|
+
q(() => {
|
|
543
|
+
const c = g();
|
|
544
|
+
l.el = c, l.open();
|
|
545
|
+
}), F(() => {
|
|
546
|
+
l.close();
|
|
547
|
+
}), G(() => {
|
|
436
548
|
const c = n.activePath;
|
|
437
|
-
i.index = n.routes.findIndex((
|
|
438
|
-
const
|
|
439
|
-
i.index !== -1 && (i.openedIndexList.push(i.index), i.scrollDistance = -
|
|
440
|
-
const v =
|
|
441
|
-
|
|
549
|
+
i.index = n.routes.findIndex((x) => x.path === c);
|
|
550
|
+
const s = n.width;
|
|
551
|
+
i.index !== -1 && (i.openedIndexList.push(i.index), i.scrollDistance = -s * i.index);
|
|
552
|
+
const v = s * n.routes.length, T = -s / 3, _ = s * (n.routes.length - 1) + s / 3;
|
|
553
|
+
l.columnWidth = s, l.width = v, l.min = T, l.max = _, l.swipeDuration = n.swipeDuration;
|
|
442
554
|
});
|
|
443
|
-
const
|
|
444
|
-
let
|
|
445
|
-
function
|
|
446
|
-
return
|
|
555
|
+
const a = `fox-swiper-navigator-${gt()}`, o = O(() => ({ width: `${n.width}px`, height: `${n.height}px` }));
|
|
556
|
+
let r = null;
|
|
557
|
+
function g() {
|
|
558
|
+
return r || (r = document.querySelector(`.${a}>.fox-swiper-navigator__inner`), r);
|
|
447
559
|
}
|
|
448
|
-
const
|
|
560
|
+
const d = O(() => `${n.width * n.routes.length}px`), m = (c, s) => ({
|
|
449
561
|
style: {
|
|
450
|
-
left: `${n.routes.findIndex((
|
|
451
|
-
const
|
|
452
|
-
return
|
|
562
|
+
left: `${n.routes.findIndex((T) => {
|
|
563
|
+
const _ = c.path ?? c.name ?? "";
|
|
564
|
+
return T.path == _;
|
|
453
565
|
}) * n.width}px`,
|
|
454
566
|
width: `${n.width}px`
|
|
455
567
|
}
|
|
456
568
|
});
|
|
457
|
-
return (c,
|
|
458
|
-
const v =
|
|
459
|
-
return
|
|
460
|
-
class:
|
|
461
|
-
style:
|
|
569
|
+
return (c, s) => {
|
|
570
|
+
const v = L("fox-router-view");
|
|
571
|
+
return y(), D(v, {
|
|
572
|
+
class: J(a),
|
|
573
|
+
style: W($(o)),
|
|
462
574
|
"view-class": "fox-swiper-navigator__item",
|
|
463
|
-
tag:
|
|
464
|
-
"view-tag-props":
|
|
575
|
+
tag: vt,
|
|
576
|
+
"view-tag-props": m,
|
|
465
577
|
multi: !0,
|
|
466
578
|
name: n.routerViewName,
|
|
467
579
|
transition: n.transition,
|
|
468
580
|
"scroll-distance": i.scrollDistance,
|
|
469
581
|
"scroll-time": n.scrollTime,
|
|
470
|
-
width:
|
|
582
|
+
width: $(d)
|
|
471
583
|
}, null, 8, ["style", "name", "transition", "scroll-distance", "scroll-time", "width"]);
|
|
472
584
|
};
|
|
473
585
|
}
|
|
474
|
-
})
|
|
475
|
-
const $t = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
586
|
+
}), Lt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
476
587
|
__proto__: null,
|
|
477
|
-
default:
|
|
588
|
+
default: $t
|
|
478
589
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
479
|
-
let
|
|
480
|
-
const
|
|
481
|
-
for (const t in
|
|
590
|
+
let Mt = "fox-";
|
|
591
|
+
const Ot = [], V = /* @__PURE__ */ Object.assign({ "/src/components/card-navigator/index.vue": Q, "/src/components/default-navigator/index.vue": tt, "/src/components/root-navigator/index.vue": ht, "/src/components/swiper-navigator/index.vue": Lt }), z = [];
|
|
592
|
+
for (const t in V) {
|
|
482
593
|
let e = /src\/components\/(.*)\/index.vue/.exec(t)[1];
|
|
483
|
-
|
|
594
|
+
Ot.indexOf(e) === -1 && z.push({
|
|
484
595
|
name: e,
|
|
485
|
-
component:
|
|
596
|
+
component: V[t].default
|
|
486
597
|
});
|
|
487
598
|
}
|
|
488
|
-
const
|
|
599
|
+
const Rt = {
|
|
600
|
+
/**
|
|
601
|
+
* 安装
|
|
602
|
+
* @param app
|
|
603
|
+
*/
|
|
489
604
|
install(t) {
|
|
490
|
-
|
|
491
|
-
t.component(`${
|
|
605
|
+
z.forEach((e) => {
|
|
606
|
+
t.component(`${Mt}${e.name}`, e.component);
|
|
492
607
|
});
|
|
493
608
|
}
|
|
494
609
|
};
|
|
495
610
|
export {
|
|
496
|
-
|
|
611
|
+
Rt as default
|
|
497
612
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
* @fox-js/navigation v4.0.1-
|
|
3
|
-
*/const w=n.defineComponent({__name:"index",props:{routerViewName:null,transition:{type:[Object,Boolean],default:!1}},setup(t){const e=t;return(o,s)=>{const f=n.resolveComponent("fox-router-view");return n.openBlock(),n.createBlock(f,{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"])}}}),ct="",P=Object.freeze(Object.defineProperty({__proto__:null,default:w},Symbol.toStringTag,{value:"Module"})),C=n.defineComponent({__name:"index",props:{routerViewName:null,transition:{type:[Object,Boolean],default:!0}},setup(t){const e=t;return(o,s)=>{const f=n.resolveComponent("fox-router-view");return n.openBlock(),n.createBlock(f,{transition:!1,multi:!1,name:e.routerViewName},{default:n.withCtx(({Component:d})=>[n.createVNode(n.Transition,{name:"fox-default-navigator__trans"},{default:n.withCtx(()=>[(n.openBlock(),n.createBlock(n.resolveDynamicComponent(d)))]),_:2},1024)]),_:1},8,["name"])}}}),lt="",I=Object.freeze(Object.defineProperty({__proto__:null,default:C},Symbol.toStringTag,{value:"Module"})),E=10;function S(t,e){return t>e&&t>E?"horizontal":e>t&&e>E?"vertical":""}function b(){const t=n.ref(0),e=n.ref(0),o=n.ref(0),s=n.ref(0),f=n.ref(0),d=n.ref(0),_=n.ref(0),g=n.ref(0),h=n.ref(0),c=n.ref(0),i=n.ref(""),r=()=>i.value==="vertical",v=()=>i.value==="horizontal",a=()=>{_.value=0,g.value=0,h.value=0,c.value=0,i.value="",o.value=0};return{move:u=>{const m=u.touches[0];_.value=m.clientX-t.value,g.value=m.clientY-e.value,f.value=m.clientX,d.value=m.clientY,h.value=Math.abs(_.value),c.value=Math.abs(g.value),s.value=Date.now()-o.value,i.value||(i.value=S(h.value,c.value))},start:u=>{a(),t.value=u.touches[0].clientX,e.value=u.touches[0].clientY,o.value=Date.now()},reset:a,startX:t,startY:e,startTime:o,duration:s,moveX:f,moveY:d,deltaX:_,deltaY:g,offsetX:h,offsetY:c,direction:i,isVertical:r,isHorizontal:v}}function B(t){return t===window}const V=t=>{const e=n.unref(t);if(B(e)){const o=e.innerWidth,s=e.innerHeight;return{top:0,left:0,right:o,bottom:s,width:o,height:s}}return e&&e.getBoundingClientRect?e.getBoundingClientRect():{top:0,left:0,right:0,bottom:0,width:0,height:0}},W=15,N=300,z=200;function j(t){t.stopPropagation()}function k(t,e){(typeof t.cancelable!="boolean"||t.cancelable)&&t.preventDefault(),e&&j(t)}function X(t,e){return t=Math.abs(t/e)/.003*(t<0?-1:1),t}function D(t,e=0,o,s=z){o==="end"?t.style.transition=`transform ${s}ms cubic-bezier(0.17, 0.89, 0.45, 1)`:t.style.transition="transform 0ms cubic-bezier(0.17, 0.89, 0.45, 1)",t.style.transform=`translate3d(${e}px, 0, 0)`}const $=new WeakMap;function A(t,e,o=500,s,f=1e3){const d={active:!0,startDistance:0,scrollDistance:0,scrollTime:0,moving:!1,transitionEndTrigger:null},_=t.previousSibling,g=b(),h=(a,p,l,u)=>{let m=p+d.startDistance;if(l==="end"){const x=V(a);let y=x.width/3;m<y?m=0:m=x.width;let T=!1;u&&u>0&&(T=!0,d.transitionEndTrigger=()=>{d.moving=!1,s&&a.classList.remove(s),m>0&&typeof e=="function"&&e()}),D(a,m,"end",u),_&&D(_,0,"",0),!T&&m>0&&typeof e=="function"&&e()}else m<0&&(m=0),D(a,m,"",0)},c=()=>{t.style.transform="",t.style.transition="",d.transitionEndTrigger?(d.transitionEndTrigger(),d.transitionEndTrigger=null,_&&setTimeout(()=>{_&&(_.style.transform="",_.style.transition="")},o)):_&&(_.style.transform="",_.style.transition="")},i=a=>{if(g.start(a),d.moving){const p=t,{transform:l}=window.getComputedStyle(p);d.scrollDistance=+l.slice(7,l.length-1).split(", ")[5]}s&&t.classList.add(s),d.startDistance=d.scrollDistance,d.transitionEndTrigger=null,d.moving=!0},r=a=>{d.moving=!0,g.move(a),g.isHorizontal()&&k(a,!0),h(t,g.deltaX.value,"",0)},v=()=>{const a=g.deltaX.value;if(a==0){s&&t.classList.remove(s);return}const p=g.duration.value;if(p<N&&Math.abs(a)>W){const u=X(a,p);h(t,u,"end",f)}else h(t,a,"end",f)};t.addEventListener("transitionend",c),t.addEventListener("touchstart",i),t.addEventListener("touchmove",r),t.addEventListener("touchend",v),t.addEventListener("touchcancel",v),$.set(t,{state:d,transitionend:c,touchstart:i,touchmove:r,touchend:v,touchcancel:v})}function U(t){const e=$.get(t);e&&($.delete(t),t.addEventListener("transitionend",e.transitionend),t.addEventListener("touchstart",e.touchstart),t.addEventListener("touchmove",e.touchmove),t.addEventListener("touchend",e.touchend),t.addEventListener("touchcancel",e.touchcancel))}const R=n.defineComponent({__name:"index",props:{dragRemove:{type:Boolean,default:!0},removeViewPage:null,removeViewPageDuration:{default:500},routerViewName:null,viewTag:{default:"div"},transition:{type:[Object,Boolean],default:!0},viewClass:{default:"fox-root-navigator__item"}},setup(t){const e=t;function o(c){return(c.params&&c.params.animationType)??"slide"}const s=(c,i,r,v)=>{if(r.opsType===3||i){const a=o(r);if(a==="pop"&&i)return;const p=i?"show":"enter",l=`fox-root-navigator__${a}-${p}-from`,u=`fox-root-navigator__${a}-${p}-active`;c.classList.add(l),c.classList.add(u)}},f=(c,i,r,v)=>{if(r.opsType===3||i){const a=o(r);if(a==="pop"&&i)return;const p=i?"show":"enter",l=`fox-root-navigator__${a}-${p}-from`,u=`fox-root-navigator__${a}-${p}-to`;c.classList.remove(l),c.classList.add(u)}},d=(c,i,r,v)=>{if(r.opsType===3||i){const a=o(r);if(a!=="pop"||!i){const p=i?"show":"enter",l=`fox-root-navigator__${a}-${p}-active`,u=`fox-root-navigator__${a}-${p}-to`;c.classList.remove(l),c.classList.remove(u)}}e.dragRemove&&!i&&r.opsType===3&&A(c,e.removeViewPage,e.removeViewPageDuration,"fox-root-navigator__item-moving",1e3)},_=(c,i,r,v)=>{if(r.opsType===3||i){const a=o(r);if(a==="pop"&&i)return;const p=i?"hide":"leave",l=`fox-root-navigator__${a}-${p}-from`,u=`fox-root-navigator__${a}-${p}-active`;c.classList.add(l),c.classList.add(u)}},g=(c,i,r,v)=>{if(r.opsType===3||i){const a=o(r);if(a==="pop"&&i)return;const p=i?"hide":"leave",l=`fox-root-navigator__${a}-${p}-from`,u=`fox-root-navigator__${a}-${p}-to`;c.classList.remove(l),c.classList.add(u)}},h=(c,i,r,v)=>{if(r.opsType===3||i){const a=o(r);if(a!=="pop"||!i){const p=i?"hide":"leave",l=`fox-root-navigator__${a}-${p}-active`,u=`fox-root-navigator__${a}-${p}-to`;c.classList.remove(l),c.classList.remove(u)}}e.dragRemove&&!i&&U(c)};return(c,i)=>{const r=n.resolveComponent("fox-router-view");return n.openBlock(),n.createBlock(r,{class:"fox-root-navigator","view-class":t.viewClass,"before-enter":s,enter:f,"after-enter":d,"before-leave":_,leave:g,"after-leave":h,multi:!0,name:e.routerViewName,"view-tag":e.viewTag,transition:e.transition},null,8,["view-class","name","view-tag","transition"])}}}),ut="",Y=Object.freeze(Object.defineProperty({__proto__:null,default:R},Symbol.toStringTag,{value:"Module"})),q={class:"fox-swiper-navigator"},F=n.defineComponent({__name:"swiper",props:{width:null,scrollDistance:null,scrollTime:null},setup(t){const e=t,o=n.computed(()=>({transform:`translate3d(${e.scrollDistance}px, 0, 0)`,width:`${e.width}`}));return(s,f)=>(n.openBlock(),n.createElementBlock("div",q,[n.createElementVNode("div",{class:"fox-swiper-navigator__inner",style:n.normalizeStyle(n.unref(o))},[n.renderSlot(s.$slots,"default")],4)]))}});let H=0;function G(){return++H}const J=15,K=300,Q=200;function Z(t){t.stopPropagation()}function tt(t,e){(typeof t.cancelable!="boolean"||t.cancelable)&&t.preventDefault(),e&&Z(t)}function et(t,e){return t=Math.abs(t/e)/.003*(t<0?-1:1),t}function L(t,e=0,o,s=Q){o==="end"?t.style.transition=`transform ${s}ms cubic-bezier(0.17, 0.89, 0.45, 1)`:t.style.transition="transform 0ms cubic-bezier(0.17, 0.89, 0.45, 1)",t.style.transform=`translate3d(${e}px, 0, 0)`}class nt{width=0;columnWidth=0;max=0;min=0;el=null;swipeDuration=360;transitionEndTrigger=null;moving=!1;startDistance=0;scrollDistance=0;getStartDistance;openPage;isPageOpened;pageOpened;transitionend=null;touchstart=null;touchmove=null;touchend=null;touchcancel=null;constructor(e,o,s,f){this.getStartDistance=e,this.openPage=o,this.isPageOpened=s,this.pageOpened=f}open(){const e=this.el,o=b(),s=(f,d,_,g)=>{let h=d+this.startDistance;const c=this.columnWidth/3;if(_==="end"){if(h==0){this.moving=!1;return}Math.abs(d)>c&&(d>0?h=this.startDistance+this.columnWidth:h=this.startDistance-this.columnWidth);let i=-h;i<0?i=0:i>this.width-this.columnWidth&&(i=this.width-this.columnWidth);const r=Math.floor(i/this.columnWidth);this.isPageOpened(r)||this.openPage(r),h=-r*this.columnWidth,g&&g>0&&(this.transitionEndTrigger=()=>{this.moving=!1,this.pageOpened(r)}),L(f,h,"end",g),this.scrollDistance=h}else{if(Math.abs(d)>c){let r=0;if(d>0?r=Math.abs(this.startDistance+this.columnWidth):r=Math.abs(this.startDistance-this.columnWidth),r>=0&&r<this.width){const v=Math.floor(r/this.columnWidth);this.isPageOpened(v)||this.openPage(v)}}let i=-h;i<this.min?i=this.min:i>this.max&&(i=this.max),L(f,-i,"",0)}};this.transitionend=()=>{e.style.transition="",this.transitionEndTrigger&&(this.transitionEndTrigger(),this.transitionEndTrigger=null)},this.touchstart=f=>{this.moving||(o.start(f),this.startDistance=this.getStartDistance(),this.transitionEndTrigger=null,this.moving=!0)},this.touchmove=f=>{o.move(f),o.isHorizontal()&&tt(f,!0),s(e,o.deltaX.value,"",0)},this.touchend=()=>{const f=o.deltaX.value;if(f==0)return;const d=o.duration.value;if(d<K&&Math.abs(f)>J){const g=et(f,d);s(e,g,"end",this.swipeDuration)}else s(e,f,"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 ot(t,e,o,s){return new nt(t,e,o,s)}const it=n.defineComponent({__name:"index",props:{activePath:null,routes:null,height:null,width:null,drag:{type:Boolean,default:!0},openViewPage:null,routerViewName:null,transition:{type:[Object,Boolean],default:!0},swipeDuration:{default:360},scrollTime:{default:0}},emits:["update:activePath"],setup(t,{emit:e}){const o=t,s=n.reactive({scrollDistance:0,index:-1,openedIndexList:[]}),h=ot(()=>s.scrollDistance,l=>{if(s.openedIndexList.indexOf(l)===-1){s.openedIndexList.push(l);const u=o.routes[l];try{o.openViewPage(u,l)}catch(m){console.error(m)}}},l=>s.openedIndexList.indexOf(l)!==-1,l=>{s.index=l,s.scrollDistance=-s.index*o.width;const u=o.routes[l];e("update:activePath",u.path)});n.onMounted(()=>{const l=v();h.el=l,h.open()}),n.onUnmounted(()=>{h.close()}),n.watchEffect(()=>{const l=o.activePath;s.index=o.routes.findIndex(T=>T.path===l);const u=o.width;s.index!==-1&&(s.openedIndexList.push(s.index),s.scrollDistance=-u*s.index);const m=u*o.routes.length,x=-u/3,y=u*(o.routes.length-1)+u/3;h.columnWidth=u,h.width=m,h.min=x,h.max=y,h.swipeDuration=o.swipeDuration});const c=`fox-swiper-navigator-${G()}`,i=n.computed(()=>({width:`${o.width}px`,height:`${o.height}px`}));let r=null;function v(){return r||(r=document.querySelector(`.${c}>.fox-swiper-navigator__inner`),r)}const a=n.computed(()=>`${o.width*o.routes.length}px`),p=(l,u)=>({style:{left:`${o.routes.findIndex(x=>{const y=l.path??l.name??"";return x.path==y})*o.width}px`,width:`${o.width}px`}});return(l,u)=>{const m=n.resolveComponent("fox-router-view");return n.openBlock(),n.createBlock(m,{class:n.normalizeClass(c),style:n.normalizeStyle(n.unref(i)),"view-class":"fox-swiper-navigator__item",tag:F,"view-tag-props":p,multi:!0,name:o.routerViewName,transition:o.transition,"scroll-distance":s.scrollDistance,"scroll-time":o.scrollTime,width:n.unref(a)},null,8,["style","name","transition","scroll-distance","scroll-time","width"])}}}),dt="",st=Object.freeze(Object.defineProperty({__proto__:null,default:it},Symbol.toStringTag,{value:"Module"}));let at="fox-";const rt=[],M=Object.assign({"/src/components/card-navigator/index.vue":P,"/src/components/default-navigator/index.vue":I,"/src/components/root-navigator/index.vue":Y,"/src/components/swiper-navigator/index.vue":st}),O=[];for(const t in M){let e=/src\/components\/(.*)\/index.vue/.exec(t)[1];rt.indexOf(e)===-1&&O.push({name:e,component:M[t].default})}return{install(t){O.forEach(e=>{t.component(`${at}${e.name}`,e.component)})}}});
|
|
1
|
+
(function(o,y){typeof exports=="object"&&typeof module<"u"?module.exports=y(require("vue")):typeof define=="function"&&define.amd?define(["vue"],y):(o=typeof globalThis<"u"?globalThis:o||self,o.FoxNavigation=y(o.Vue))})(this,function(o){"use strict";/*!
|
|
2
|
+
* @fox-js/navigation v4.0.1-6 Wed Jan 03 2024 16:14:47 GMT+0800 (中国标准时间)
|
|
3
|
+
*/const R=Object.freeze(Object.defineProperty({__proto__:null,default:o.defineComponent({__name:"index",props:{routerViewName:null,transition:{type:[Object,Boolean],default:!1}},setup(t){const e=t;return(n,s)=>{const m=o.resolveComponent("fox-router-view");return o.openBlock(),o.createBlock(m,{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"})),I=Object.freeze(Object.defineProperty({__proto__:null,default:o.defineComponent({__name:"index",props:{routerViewName:null,transition:{type:[Object,Boolean],default:!0}},setup(t){const e=t;return(n,s)=>{const m=o.resolveComponent("fox-router-view");return o.openBlock(),o.createBlock(m,{transition:!1,multi:!1,name:e.routerViewName},{default:o.withCtx(({Component:h})=>[o.createVNode(o.Transition,{name:"fox-default-navigator__trans"},{default:o.withCtx(()=>[(o.openBlock(),o.createBlock(o.resolveDynamicComponent(h)))]),_:2},1024)]),_:1},8,["name"])}}})},Symbol.toStringTag,{value:"Module"})),b=10;function S(t,e){return t>e&&t>b?"horizontal":e>t&&e>b?"vertical":""}function L(){const t=o.ref(0),e=o.ref(0),n=o.ref(0),s=o.ref(0),m=o.ref(0),h=o.ref(0),v=o.ref(0),d=o.ref(0),u=o.ref(0),r=o.ref(0),i=o.ref(""),c=()=>i.value==="vertical",_=()=>i.value==="horizontal",f=()=>{v.value=0,d.value=0,u.value=0,r.value=0,i.value="",n.value=0};return{move:a=>{const g=a.touches[0];v.value=g.clientX-t.value,d.value=g.clientY-e.value,m.value=g.clientX,h.value=g.clientY,u.value=Math.abs(v.value),r.value=Math.abs(d.value),s.value=Date.now()-n.value,i.value||(i.value=S(u.value,r.value))},start:a=>{f(),t.value=a.touches[0].clientX,e.value=a.touches[0].clientY,n.value=Date.now()},reset:f,startX:t,startY:e,startTime:n,duration:s,moveX:m,moveY:h,deltaX:v,deltaY:d,offsetX:u,offsetY:r,direction:i,isVertical:c,isHorizontal:_}}function B(t){return t===window}const V=t=>{const e=o.unref(t);if(B(e)){const n=e.innerWidth,s=e.innerHeight;return{top:0,left:0,right:n,bottom:s,width:n,height:s}}return e&&e.getBoundingClientRect?e.getBoundingClientRect():{top:0,left:0,right:0,bottom:0,width:0,height:0}},W=15,N=300,z=200;function j(t){t.stopPropagation()}function k(t,e){(typeof t.cancelable!="boolean"||t.cancelable)&&t.preventDefault(),e&&j(t)}function X(t,e,n=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*n}function $(t,e=0,n,s=z){n==="end"?t.style.transition=`transform ${s}ms cubic-bezier(0.17, 0.89, 0.45, 1)`:t.style.transition="transform 0ms cubic-bezier(0.17, 0.89, 0.45, 1)",t.style.transform=`translate3d(${e}px, 0, 0)`}const E=new WeakMap;function A(t,e,n,s,m=500,h,v=1e3){const d={active:!0,startDistance:0,scrollDistance:0,scrollTime:0,moving:!1,transitionEndTrigger:null},u=t.previousSibling,r=L(),i=(a,g,T,x)=>{let w=g+d.startDistance;if(T==="end"){const D=V(a);let rt=D.width*e;w<rt?w=0:w=D.width;let C=!1;x&&x>0&&(C=!0,d.transitionEndTrigger=()=>{d.moving=!1,h&&a.classList.remove(h),w>0&&typeof s=="function"&&s()}),$(a,w,"end",x),u&&$(u,0,"",0),!C&&w>0&&typeof s=="function"&&(d.moving=!1,s())}else w<0&&(w=0),$(a,w,"",0)},c=()=>{t.style.transform="",t.style.transition="",d.transitionEndTrigger?(d.transitionEndTrigger(),d.transitionEndTrigger=null,u&&setTimeout(()=>{u&&(u.style.transform="",u.style.transition="")},m)):u&&(u.style.transform="",u.style.transition="")},_=/^matrix\((.+)\)$/,f=a=>{if(r.start(a),d.scrollDistance=0,d.moving){const g=t,{transform:T}=window.getComputedStyle(g);if(T){const x=_.exec(T);if(x){const D=x[1].split(/,\s*/);d.scrollDistance=+D[4]}}}h&&t.classList.add(h),d.startDistance=d.scrollDistance,d.transitionEndTrigger=null,d.moving=!0},p=a=>{d.moving=!0,r.move(a),r.isHorizontal()&&k(a,!0),i(t,r.deltaX.value,"",0)},l=()=>{if(r.isVertical()){i(t,0,"end",v);return}const a=r.deltaX.value;if(a===0){h&&t.classList.remove(h),d.moving=!1;return}const g=r.duration.value;if(g<N&&Math.abs(a)>W){const x=X(a,g,n);i(t,x,"end",v)}else i(t,a,"end",v)};t.addEventListener("transitionend",c),t.addEventListener("touchstart",f),t.addEventListener("touchmove",p),t.addEventListener("touchend",l),t.addEventListener("touchcancel",l),E.set(t,{state:d,transitionend:c,touchstart:f,touchmove:p,touchend:l,touchcancel:l})}function U(t){const e=E.get(t);e&&(E.delete(t),t.addEventListener("transitionend",e.transitionend),t.addEventListener("touchstart",e.touchstart),t.addEventListener("touchmove",e.touchmove),t.addEventListener("touchend",e.touchend),t.addEventListener("touchcancel",e.touchcancel))}const Y=Object.freeze(Object.defineProperty({__proto__:null,default:o.defineComponent({__name:"index",props:{dragRemove:{type:Boolean,default:!0},removeViewPage:null,removeMoveRatio:{default:.5},momentumReduceRatio:{default:1},removeViewPageDuration:{default:500},routerViewName:null,viewTag:{default:"div"},transition:{type:[Object,Boolean],default:!0},viewClass:{default:"fox-root-navigator__item"}},setup(t){const e=t;function n(r){return(r.params&&r.params.animationType)??"slide"}const s=(r,i,c,_)=>{if(c.opsType===3||i){const f=n(c);if(f==="pop"&&i)return;const p=i?"show":"enter",l=`fox-root-navigator__${f}-${p}-from`,a=`fox-root-navigator__${f}-${p}-active`;r.classList.add(l),r.classList.add(a)}},m=(r,i,c,_)=>{if(c.opsType===3||i){const f=n(c);if(f==="pop"&&i)return;const p=i?"show":"enter",l=`fox-root-navigator__${f}-${p}-from`,a=`fox-root-navigator__${f}-${p}-to`;r.classList.remove(l),r.classList.add(a)}},h=(r,i,c,_)=>{if(c.opsType===3||i){const f=n(c);if(f!=="pop"||!i){const p=i?"show":"enter",l=`fox-root-navigator__${f}-${p}-active`,a=`fox-root-navigator__${f}-${p}-to`;r.classList.remove(l),r.classList.remove(a)}}e.dragRemove&&!i&&c.opsType===3&&A(r,e.removeMoveRatio,e.momentumReduceRatio,e.removeViewPage,e.removeViewPageDuration,"fox-root-navigator__item-moving",1e3)},v=(r,i,c,_)=>{if(c.opsType===3||i){const f=n(c);if(f==="pop"&&i)return;const p=i?"hide":"leave",l=`fox-root-navigator__${f}-${p}-from`,a=`fox-root-navigator__${f}-${p}-active`;r.classList.add(l),r.classList.add(a)}},d=(r,i,c,_)=>{if(c.opsType===3||i){const f=n(c);if(f==="pop"&&i)return;const p=i?"hide":"leave",l=`fox-root-navigator__${f}-${p}-from`,a=`fox-root-navigator__${f}-${p}-to`;r.classList.remove(l),r.classList.add(a)}},u=(r,i,c,_)=>{if(c.opsType===3||i){const f=n(c);if(f!=="pop"||!i){const p=i?"hide":"leave",l=`fox-root-navigator__${f}-${p}-active`,a=`fox-root-navigator__${f}-${p}-to`;r.classList.remove(l),r.classList.remove(a)}}e.dragRemove&&!i&&U(r)};return(r,i)=>{const c=o.resolveComponent("fox-router-view");return o.openBlock(),o.createBlock(c,{class:"fox-root-navigator","view-class":t.viewClass,"before-enter":s,enter:m,"after-enter":h,"before-leave":v,leave:d,"after-leave":u,multi:!0,name:e.routerViewName,"view-tag":e.viewTag,transition:e.transition},null,8,["view-class","name","view-tag","transition"])}}})},Symbol.toStringTag,{value:"Module"})),q={class:"fox-swiper-navigator"},F=o.defineComponent({__name:"swiper",props:{width:null,scrollDistance:null,scrollTime:null},setup(t){const e=t,n=o.computed(()=>({transform:`translate3d(${e.scrollDistance}px, 0, 0)`,width:`${e.width}`}));return(s,m)=>(o.openBlock(),o.createElementBlock("div",q,[o.createElementVNode("div",{class:"fox-swiper-navigator__inner",style:o.normalizeStyle(o.unref(n))},[o.renderSlot(s.$slots,"default")],4)]))}});let H=0;function G(){return++H}const J=15,K=300,Q=200;function Z(t){t.stopPropagation()}function tt(t,e){(typeof t.cancelable!="boolean"||t.cancelable)&&t.preventDefault(),e&&Z(t)}function et(t,e,n=1){return t=Math.abs(t/e)/.003*(t<0?-1:1),t*n}function M(t,e=0,n,s=Q){n==="end"?t.style.transition=`transform ${s}ms cubic-bezier(0.17, 0.89, 0.45, 1)`:t.style.transition="transform 0ms cubic-bezier(0.17, 0.89, 0.45, 1)",t.style.transform=`translate3d(${e}px, 0, 0)`}class nt{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,s,m,h,v){this.getStartDistance=e,this.openPage=n,this.isPageOpened=s,this.pageOpened=m,this.moveRatio=h,this.momentumReduceRatio=v}open(){const e=this.el,n=L(),s=(m,h,v,d)=>{let u=h+this.startDistance;const r=this.columnWidth*this.moveRatio;if(v==="end"){if(u==0){this.moving=!1;return}Math.abs(h)>r&&(h>0?u=this.startDistance+this.columnWidth:u=this.startDistance-this.columnWidth);let i=-u;i<0?i=0:i>this.width-this.columnWidth&&(i=this.width-this.columnWidth);const c=Math.floor(i/this.columnWidth);this.isPageOpened(c)||this.openPage(c),u=-c*this.columnWidth,d&&d>0&&(this.transitionEndTrigger=()=>{this.moving=!1,this.pageOpened(c)}),M(m,u,"end",d),this.scrollDistance=u}else{if(Math.abs(h)>r){let c=0;if(h>0?c=Math.abs(this.startDistance+this.columnWidth):c=Math.abs(this.startDistance-this.columnWidth),c>=0&&c<this.width){const _=Math.floor(c/this.columnWidth);this.isPageOpened(_)||this.openPage(_)}}let i=-u;i<this.min?i=this.min:i>this.max&&(i=this.max),M(m,-i,"",0)}};this.transitionend=()=>{e.style.transition="",this.transitionEndTrigger&&(this.transitionEndTrigger(),this.transitionEndTrigger=null)},this.touchstart=m=>{this.moving||(n.start(m),this.startDistance=this.getStartDistance(),this.transitionEndTrigger=null,this.moving=!0)},this.touchmove=m=>{n.move(m),n.isHorizontal()&&tt(m,!0),s(e,n.deltaX.value,"",0)},this.touchend=()=>{if(n.isVertical()){s(e,0,"end",this.swipeDuration);return}const m=n.deltaX.value;if(m==0)return;const h=n.duration.value;if(h<K&&Math.abs(m)>J){const d=et(m,h,this.momentumReduceRatio);s(e,d,"end",this.swipeDuration)}else s(e,m,"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 ot(t,e,n,s,m,h){return new nt(t,e,n,s,m,h)}const it=Object.freeze(Object.defineProperty({__proto__:null,default:o.defineComponent({__name:"index",props:{activePath:null,routes:null,height:null,width:null,drag:{type:Boolean,default:!0},openViewPage:null,routerViewName:null,moveRatio:{default:.5},momentumReduceRatio:{default:1},transition:{type:[Object,Boolean],default:!0},swipeDuration:{default:360},scrollTime:{default:0}},emits:["update:activePath"],setup(t,{emit:e}){const n=t,s=o.reactive({scrollDistance:0,index:-1,openedIndexList:[]}),u=ot(()=>s.scrollDistance,l=>{if(s.openedIndexList.indexOf(l)===-1){s.openedIndexList.push(l);const a=n.routes[l];try{n.openViewPage(a,l)}catch(g){console.error(g)}}},l=>s.openedIndexList.indexOf(l)!==-1,l=>{s.index=l,s.scrollDistance=-s.index*n.width;const a=n.routes[l];e("update:activePath",a.path)},n.moveRatio,n.momentumReduceRatio);o.onMounted(()=>{const l=_();u.el=l,u.open()}),o.onUnmounted(()=>{u.close()}),o.watchEffect(()=>{const l=n.activePath;s.index=n.routes.findIndex(w=>w.path===l);const a=n.width;s.index!==-1&&(s.openedIndexList.push(s.index),s.scrollDistance=-a*s.index);const g=a*n.routes.length,T=-a/3,x=a*(n.routes.length-1)+a/3;u.columnWidth=a,u.width=g,u.min=T,u.max=x,u.swipeDuration=n.swipeDuration});const r=`fox-swiper-navigator-${G()}`,i=o.computed(()=>({width:`${n.width}px`,height:`${n.height}px`}));let c=null;function _(){return c||(c=document.querySelector(`.${r}>.fox-swiper-navigator__inner`),c)}const f=o.computed(()=>`${n.width*n.routes.length}px`),p=(l,a)=>({style:{left:`${n.routes.findIndex(T=>{const x=l.path??l.name??"";return T.path==x})*n.width}px`,width:`${n.width}px`}});return(l,a)=>{const g=o.resolveComponent("fox-router-view");return o.openBlock(),o.createBlock(g,{class:o.normalizeClass(r),style:o.normalizeStyle(o.unref(i)),"view-class":"fox-swiper-navigator__item",tag:F,"view-tag-props":p,multi:!0,name:n.routerViewName,transition:n.transition,"scroll-distance":s.scrollDistance,"scroll-time":n.scrollTime,width:o.unref(f)},null,8,["style","name","transition","scroll-distance","scroll-time","width"])}}})},Symbol.toStringTag,{value:"Module"}));let st="fox-";const at=[],O=Object.assign({"/src/components/card-navigator/index.vue":R,"/src/components/default-navigator/index.vue":I,"/src/components/root-navigator/index.vue":Y,"/src/components/swiper-navigator/index.vue":it}),P=[];for(const t in O){let e=/src\/components\/(.*)\/index.vue/.exec(t)[1];at.indexOf(e)===-1&&P.push({name:e,component:O[t].default})}return{install(t){P.forEach(e=>{t.component(`${st}${e.name}`,e.component)})}}});
|
package/package.json
CHANGED
|
@@ -1,29 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fox-js/navigation",
|
|
3
|
-
"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "4.0.1-7",
|
|
4
5
|
"description": "fox navigation",
|
|
5
6
|
"author": "jiangcheng",
|
|
6
7
|
"keywords": [
|
|
7
8
|
"fox",
|
|
8
9
|
"navigation"
|
|
9
10
|
],
|
|
10
|
-
"main": "dist/index.umd.js",
|
|
11
|
-
"module": "dist/index.esm.js",
|
|
11
|
+
"main": "./dist/index.umd.js",
|
|
12
|
+
"module": "./dist/index.esm.js",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"style": "./dist/style.css",
|
|
12
15
|
"exports": {
|
|
13
16
|
".": {
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
},
|
|
18
|
-
"require": {
|
|
19
|
-
"node": "./dist/index.umd.js",
|
|
20
|
-
"default": "./dist/index.umd.js"
|
|
21
|
-
}
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"require": "./dist/index.umd.js",
|
|
19
|
+
"import": "./dist/index.esm.js"
|
|
22
20
|
},
|
|
23
|
-
"./style.css": "./dist/style.css"
|
|
21
|
+
"./style.css": "./dist/style.css",
|
|
22
|
+
"./*": "./*"
|
|
24
23
|
},
|
|
25
|
-
"style": "dist/style.css",
|
|
26
|
-
"typings": "dist/index.d.ts",
|
|
27
24
|
"license": "",
|
|
28
25
|
"publishConfig": {
|
|
29
26
|
"access": "public"
|