@fox-js/navigation 4.0.1-4 → 4.0.1-5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +2 -2
- package/dist/index.esm.js +2 -2
- package/dist/index.umd.js +3 -3
- package/package.json +3 -3
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-4 Mon Jan 30 2023 14:43:23 GMT+0800 (中国标准时间)
|
|
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;
|
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent as D, resolveComponent as b, openBlock as w, createBlock as T, withCtx as P, createVNode as z, Transition as j, resolveDynamicComponent as B, ref as g, unref as E, computed as M, createElementBlock as X, createElementVNode as A, normalizeStyle as V, renderSlot as U, reactive as R, onMounted as Y, onUnmounted as k, watchEffect as H, normalizeClass as q } from "vue";
|
|
2
2
|
/*!
|
|
3
|
-
* @fox-js/navigation v4.0.1-
|
|
3
|
+
* @fox-js/navigation v4.0.1-4 Mon Jan 30 2023 14:43:23 GMT+0800 (中国标准时间)
|
|
4
4
|
*/
|
|
5
5
|
const F = /* @__PURE__ */ D({
|
|
6
6
|
__name: "index",
|
|
@@ -151,7 +151,7 @@ function rt(t, e, n = 500, i, d = 1e3) {
|
|
|
151
151
|
v < 0 && (v = 0), L(s, v, "", 0);
|
|
152
152
|
}, r = () => {
|
|
153
153
|
t.style.transform = "", t.style.transition = "", u.transitionEndTrigger ? (u.transitionEndTrigger(), u.transitionEndTrigger = null, m && setTimeout(() => {
|
|
154
|
-
|
|
154
|
+
m && (m.style.transform = "", m.style.transition = "");
|
|
155
155
|
}, n)) : m && (m.style.transform = "", m.style.transition = "");
|
|
156
156
|
}, o = (s) => {
|
|
157
157
|
if (p.start(s), u.moving) {
|
package/dist/index.umd.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(n,w){typeof exports=="object"&&typeof module<"u"?module.exports=w(require("vue")):typeof define=="function"&&define.amd?define(["vue"],w):(n=typeof globalThis<"u"?globalThis:n||self,n.
|
|
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,z=300,N=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=N){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<z&&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"},H=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 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 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:H,"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(n,w){typeof exports=="object"&&typeof module<"u"?module.exports=w(require("vue")):typeof define=="function"&&define.amd?define(["vue"],w):(n=typeof globalThis<"u"?globalThis:n||self,n.FoxNavigation=w(n.Vue))})(this,function(n){"use strict";/*!
|
|
2
|
+
* @fox-js/navigation v4.0.1-4 Mon Jan 30 2023 14:43:23 GMT+0800 (中国标准时间)
|
|
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)})}}});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fox-js/navigation",
|
|
3
|
-
"version": "4.0.1-
|
|
3
|
+
"version": "4.0.1-5",
|
|
4
4
|
"description": "fox navigation",
|
|
5
5
|
"author": "jiangcheng",
|
|
6
6
|
"keywords": [
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
14
|
"import": {
|
|
15
|
-
"node": "./dist/index.
|
|
15
|
+
"node": "./dist/index.esm.js",
|
|
16
16
|
"default": "./dist/index.esm.js"
|
|
17
17
|
},
|
|
18
18
|
"require": {
|
|
19
|
-
"node": "./dist/index.
|
|
19
|
+
"node": "./dist/index.umd.js",
|
|
20
20
|
"default": "./dist/index.umd.js"
|
|
21
21
|
}
|
|
22
22
|
},
|