@fox-js/navigation 4.0.1-7 → 4.0.1-8

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 CHANGED
@@ -1,3 +1,3 @@
1
1
  "use strict";/*!
2
- * @fox-js/navigation v4.0.1-6 Wed Jan 03 2024 16:14:47 GMT+0800 (中国标准时间)
2
+ * @fox-js/navigation v4.0.1-7 Fri Jan 05 2024 00:43:18 GMT+0800 (中国标准时间)
3
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.esm.js CHANGED
@@ -1,6 +1,6 @@
1
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-6 Wed Jan 03 2024 16:14:47 GMT+0800 (中国标准时间)
3
+ * @fox-js/navigation v4.0.1-7 Fri Jan 05 2024 00:43:18 GMT+0800 (中国标准时间)
4
4
  */
5
5
  const K = /* @__PURE__ */ E({
6
6
  __name: "index",
package/dist/index.umd.js CHANGED
@@ -1,3 +1,3 @@
1
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 (中国标准时间)
2
+ * @fox-js/navigation v4.0.1-7 Fri Jan 05 2024 00:43:18 GMT+0800 (中国标准时间)
3
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,7 +1,7 @@
1
1
  {
2
2
  "name": "@fox-js/navigation",
3
3
  "type": "module",
4
- "version": "4.0.1-7",
4
+ "version": "4.0.1-8",
5
5
  "description": "fox navigation",
6
6
  "author": "jiangcheng",
7
7
  "keywords": [