acdr-ui/dist/build/mp-weixin/node-modules/wot-design-uni/components/wd-transition/wd-transition.js

2 lines
3.2 KiB
JavaScript
Raw Normal View History

2024-09-19 07:20:14 +08:00
"use strict";var e=Object.defineProperty,a=Object.defineProperties,t=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable,u=(a,t,l)=>t in a?e(a,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):a[t]=l,o=(e,a,t)=>new Promise(((l,r)=>{var n=e=>{try{o(t.next(e))}catch(a){r(a)}},u=e=>{try{o(t.throw(e))}catch(a){r(a)}},o=e=>e.done?l(e.value):Promise.resolve(e.value).then(n,u);o((t=t.apply(e,a)).next())}));const v=require("../../../../common/vendor.js"),i=v.defineComponent((s=((e,a)=>{for(var t in a||(a={}))r.call(a,t)&&u(e,t,a[t]);if(l)for(var t of l(a))n.call(a,t)&&u(e,t,a[t]);return e})({},{name:"wd-transition",options:{addGlobalClass:!0,virtualHost:!0,styleIsolation:"shared"}}),c={props:v.transitionProps,emits:["click","before-enter","enter","before-leave","leave","after-leave","after-enter"],setup(e,{emit:a}){const t=e=>e?{enter:`wd-${e}-enter wd-${e}-enter-active`,"enter-to":`wd-${e}-enter-to wd-${e}-enter-active`,leave:`wd-${e}-leave wd-${e}-leave-active`,"leave-to":`wd-${e}-leave-to wd-${e}-leave-active`}:{enter:`${l.enterClass} ${l.enterActiveClass}`,"enter-to":`${l.enterToClass} ${l.enterActiveClass}`,leave:`${l.leaveClass} ${l.leaveActiveClass}`,"leave-to":`${l.leaveToClass} ${l.leaveActiveClass}`},l=e,r=a,n=v.ref(!1),u=v.ref(!1),i=v.ref(""),s=v.ref(!1),c=v.ref(300),d=v.ref(""),f=v.ref(null),m=v.ref(null),b=v.ref(null),p=v.computed((()=>`-webkit-transition-duration:${c.value}ms;transition-duration:${c.value}ms;${u.value?"":"display: none;"}${l.customStyle}`)),w=v.computed((()=>`wd-transition ${l.customClass} ${d.value}`));function y(){r("click")}function $(){f.value=new v.AbortablePromise((e=>o(this,null,(function*(){try{const a=t(l.name),o=v.isObj(l.duration)?l.duration.enter:l.duration;i.value="enter",r("before-enter"),m.value=v.requestAnimationFrame(),yield m.value,r("enter"),d.value=a.enter,c.value=o,m.value=v.requestAnimationFrame(),yield m.value,n.value=!0,u.value=!0,m.value=v.requestAnimationFrame(),yield m.value,m.value=null,s.value=!1,d.value=a["enter-to"],e()}catch(a){}}))))}function h(){s.value||(s.value=!0,"leave"===i.value?r("after-leave"):"enter"===i.value&&r("after-enter"),!l.show&&u.value&&(u.value=!1))}return v.onBeforeMount((()=>{l.show&&$()})),v.watch((()=>l.show),(e=>{e?(v.isPromise(f.value)&&f.value.abort(),v.isPromise(m.value)&&m.value.abort(),v.isPromise(b.value)&&b.value.abort(),f.value=null,m.value=null,b.value=null,$()):function(){o(this,null,(function*(){if(!f.value)return s.value=!1,h();try{if(yield f.value,!u.value)return;const e=t(l.name),a=v.isObj(l.duration)?l.duration.leave:l.duration;i.value="leave",r("before-leave"),c.value=a,b.value=v.requestAnimationFrame(),yield b.value,r("leave"),d.value=e.leave,b.value=v.requestAnimationFrame(),yield b.value,s.value=!1,d.value=e["leave-to"],b.value=function(e){return new v.AbortablePromise((a=>{const t=setTimeout((()=>{clearTimeout(t),a()}),e)}))}(c.value),yield b.value,b.value=null,h(),f.value=null}catch(e){}}))}()}),{deep:!0}),(e,a)=>v.e({a:n.value},n.value?{b:v.n(w.value),c:v.s(p.value),d:v.o(h),e:v.o(y)}:{})}},a(s,t(c))));var s,c;const d=v._export_sfc(i,[["__scopeId","data-v-41e83fd8"]]);wx.createComponent(d);