@vueuse/motion
Advanced tools
Comparing version 1.0.4 to 1.0.5
/*! | ||
* @vueuse/motion v1.0.2 | ||
* @vueuse/motion v1.0.5 | ||
* (c) 2021 | ||
@@ -20,2 +20,2 @@ * @license MIT | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */var dn=function(){return(dn=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)},vn=function(e,t){return function(n){return Math.max(Math.min(n,t),e)}},hn=function(e){return e%1?Number(e.toFixed(5)):e},yn=/(-)?([\d]*\.?[\d])+/g,gn=/(#[0-9a-f]{6}|#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))/gi,mn=/^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))$/i;function bn(e){return"string"==typeof e}var _n={test:function(e){return"number"==typeof e},parse:parseFloat,transform:function(e){return e}},wn=dn(dn({},_n),{transform:vn(0,1)}),En=dn(dn({},_n),{default:1}),On=function(e){return{test:function(t){return bn(t)&&t.endsWith(e)&&1===t.split(" ").length},parse:parseFloat,transform:function(t){return""+t+e}}},Nn=On("deg"),Vn=On("%"),kn=On("px"),xn=dn(dn({},Vn),{parse:function(e){return Vn.parse(e)/100},transform:function(e){return Vn.transform(100*e)}}),Rn=function(e,t){return function(n){return bn(n)&&mn.test(n)&&n.startsWith(e)||t&&Object.prototype.hasOwnProperty.call(n,t)}},Sn=function(e,t,n){return function(o){var r;if(!bn(o))return o;var s=o.match(yn),i=s[1],a=s[2],c=s[3];return(r={})[e]=parseFloat(s[0]),r[t]=parseFloat(i),r[n]=parseFloat(a),r.alpha=void 0!==c?parseFloat(c):1,r}},Cn={test:Rn("hsl","hue"),parse:Sn("hue","saturation","lightness"),transform:function(e){var t=e.saturation,n=e.lightness,o=e.alpha,r=void 0===o?1:o;return"hsla("+Math.round(e.hue)+", "+Vn.transform(hn(t))+", "+Vn.transform(hn(n))+", "+hn(wn.transform(r))+")"}},jn=vn(0,255),$n=dn(dn({},_n),{transform:function(e){return Math.round(jn(e))}}),Dn={test:Rn("rgb","red"),parse:Sn("red","green","blue"),transform:function(e){var t=e.green,n=e.blue,o=e.alpha,r=void 0===o?1:o;return"rgba("+$n.transform(e.red)+", "+$n.transform(t)+", "+$n.transform(n)+", "+hn(wn.transform(r))+")"}};var In={test:Rn("#"),parse:function(e){var t="",n="",o="",r="";return e.length>5?(t=e.substr(1,2),n=e.substr(3,2),o=e.substr(5,2),r=e.substr(7,2)):(t=e.substr(1,1),n=e.substr(2,1),o=e.substr(3,1),r=e.substr(4,1),t+=t,n+=n,o+=o,r+=r),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(o,16),alpha:r?parseInt(r,16)/255:1}},transform:Dn.transform},Tn={test:function(e){return Dn.test(e)||In.test(e)||Cn.test(e)},parse:function(e){return Dn.test(e)?Dn.parse(e):Cn.test(e)?Cn.parse(e):In.parse(e)},transform:function(e){return bn(e)?e:e.hasOwnProperty("red")?Dn.transform(e):Cn.transform(e)}},Pn="${c}",Mn="${n}";function An(e){var t=[],n=0,o=e.match(gn);o&&(n=o.length,e=e.replace(gn,Pn),t.push.apply(t,o.map(Tn.parse)));var r=e.match(yn);return r&&(e=e.replace(yn,Mn),t.push.apply(t,r.map(_n.parse))),{values:t,numColors:n,tokenised:e}}function Fn(e){return An(e).values}function Ln(e){var t=An(e),n=t.numColors,o=t.tokenised,r=t.values.length;return function(e){for(var t=o,s=0;s<r;s++)t=t.replace(s<n?Pn:Mn,s<n?Tn.transform(e[s]):hn(e[s]));return t}}var zn=function(e){return"number"==typeof e?0:e};var Un={test:function(e){var t,n,o,r;return isNaN(e)&&bn(e)&&(null!==(n=null===(t=e.match(yn))||void 0===t?void 0:t.length)&&void 0!==n?n:0)+(null!==(r=null===(o=e.match(gn))||void 0===o?void 0:o.length)&&void 0!==r?r:0)>0},parse:Fn,createTransformer:Ln,getAnimatableNone:function(e){var t=Fn(e);return Ln(e)(t.map(zn))}},Bn=new Set(["brightness","contrast","saturate","opacity"]);function Wn(e){var t=e.slice(0,-1).split("("),n=t[0],o=t[1];if("drop-shadow"===n)return e;var r=(o.match(yn)||[])[0];if(!r)return e;var s=o.replace(r,""),i=Bn.has(n)?1:0;return r!==o&&(i*=100),n+"("+i+s+")"}var Hn=/([a-z-]*)\(.*?\)/g,Zn=dn(dn({},Un),{getAnimatableNone:function(e){var t=e.match(Hn);return t?t.map(Wn).join(" "):e}});const Xn={..._n,transform:Math.round},Yn={color:Tn,backgroundColor:Tn,outlineColor:Tn,fill:Tn,stroke:Tn,borderColor:Tn,borderTopColor:Tn,borderRightColor:Tn,borderBottomColor:Tn,borderLeftColor:Tn,borderWidth:kn,borderTopWidth:kn,borderRightWidth:kn,borderBottomWidth:kn,borderLeftWidth:kn,borderRadius:kn,radius:kn,borderTopLeftRadius:kn,borderTopRightRadius:kn,borderBottomRightRadius:kn,borderBottomLeftRadius:kn,width:kn,maxWidth:kn,height:kn,maxHeight:kn,size:kn,top:kn,right:kn,bottom:kn,left:kn,padding:kn,paddingTop:kn,paddingRight:kn,paddingBottom:kn,paddingLeft:kn,margin:kn,marginTop:kn,marginRight:kn,marginBottom:kn,marginLeft:kn,rotate:Nn,rotateX:Nn,rotateY:Nn,rotateZ:Nn,scale:En,scaleX:En,scaleY:En,scaleZ:En,skew:Nn,skewX:Nn,skewY:Nn,distance:kn,translateX:kn,translateY:kn,translateZ:kn,x:kn,y:kn,z:kn,perspective:kn,transformPerspective:kn,opacity:wn,originX:xn,originY:xn,originZ:kn,zIndex:Xn,filter:Zn,WebkitFilter:Zn,fillOpacity:wn,strokeOpacity:wn,numOctaves:Xn},Jn=e=>Yn[e],Kn=(e,t)=>t&&"number"==typeof e&&t.transform?t.transform(e):e;function qn(e={}){const n=t.reactive({...e}),o=t.computed((()=>{const e={};for(const[t,o]of Object.entries(n)){const n=Jn(t),r=Kn(o,n);e[t]=r}return e}));return{state:n,style:o}}function Gn(e){const n=t.ref(e);let o;const{state:r,style:s}=qn(),i=t.watch(n,(e=>{if(e){for(const t of Object.keys(Yn))null!=e.style[t]&&""!==e.style[t]&&(r[t]=e.style[t]);o&&Object.assign(e.style,o)}})),a=t.watch(s,(e=>{n.value&&n.value.style?Object.assign(n.value.style,e):o=e}),{immediate:!0});return{style:r,stop:()=>{i(),a()}}}const Qn={x:"translateX",y:"translateY",z:"translateZ"};function eo(e={},n=!0){const o=t.reactive({...e}),r=t.computed((()=>{let e="",t=!1;for(const[n,r]of Object.entries(o)){const o=Jn(n),s=Kn(r,o);e+=`${Qn[n]||n}(${s}) `,"z"!==n&&"translateZ"!==n||(t=!0)}return!t&&n?e+="translateZ(0)":e=e.trim(),e}));return{state:o,transform:r}}function to(e){const n=t.ref(e);let o;const{state:r,transform:s}=eo(),i=t.watch(n,(e=>{e&&o&&(e.style.transform=o)})),a=t.watch(s,(e=>{n.value&&n.value.style?n.value.style.transform=e:o=e}),{immediate:!0});return{transform:r,stop:()=>{i(),a()}}}const no=["","X","Y","Z"],oo=["transformPerspective","x","y","z"];["perspective","translate","scale","rotate","skew"].forEach((e=>{no.forEach((t=>{oo.push(e+t)}))}));const ro=new Set(oo);function so(e){return ro.has(e)}function io(e){const n=t.ref(e),{style:o}=Gn(n),{transform:r}=to(n),s=t.reactive({});return t.watch(s,(e=>{for(const t in e){const n=so(t)?r:o;n[t]&&n[t]===e[t]||(n[t]=e[t])}}),{immediate:!0,deep:!0}),{motionProperties:s,style:o,transform:r}}function ao(e={}){const n=t.ref(e),o=t.ref();return{state:t.computed((()=>{if(o.value)return n.value[o.value]})),variant:o}}function co(e,n={},o){const r=t.ref(n),s=t.ref(e),{motionProperties:i}=io(s),{variant:a,state:c}=ao(r),l={target:s,variant:a,variants:r,state:c,motionProperties:i,...cn(i,r)};return fn(l,o),l}const lo=["initial","enter","leave","visible","hovered","tapped","focused","delay"],uo=e=>{const o=(o,s,i)=>{const a=t.ref(e||{});((e,t)=>{e&&e.props&&(e.props.variants&&n.isObject(e.props.variants)&&(t.value={...t.value,...e.props.variants}),lo.forEach((o=>{if("delay"!==o)e.props&&e.props[o]&&n.isObject(e.props[o])&&(t.value[o]=e.props[o]);else if(e.props&&e.props[o]&&n.isNumber(e.props[o])){const n=e.props[o];t&&t.value&&(t.value.enter&&(t.value.enter.transition||(t.value.enter.transition={}),t.value.enter.transition={...t.value.enter.transition,delay:n}),t.value.visible&&(t.value.visible.transition||(t.value.visible.transition={}),t.value.visible.transition={...t.value.visible.transition,delay:n}))}})))})(i,a);const c=co(o,a);s.value&&(r[s.value]=c)},s=(e,t,n)=>{t.value&&r[t.value]&&delete r[t.value]};return{created:o,unmounted:s,bind:o,unbind:s}},po={initial:{opacity:0},enter:{opacity:1}},fo={initial:{opacity:0},visible:{opacity:1}},vo={initial:{scale:0,opacity:0},enter:{scale:1,opacity:1}},ho={initial:{scale:0,opacity:0},visible:{scale:1,opacity:1}},yo={initial:{x:-100,rotate:90,opacity:0},enter:{x:0,rotate:0,opacity:1}},go={initial:{x:-100,rotate:90,opacity:0},visible:{x:0,rotate:0,opacity:1}},mo={initial:{x:100,rotate:-90,opacity:0},enter:{x:0,rotate:0,opacity:1}},bo={initial:{x:100,rotate:-90,opacity:0},visible:{x:0,rotate:0,opacity:1}},_o={initial:{y:-100,rotate:-90,opacity:0},enter:{y:0,rotate:0,opacity:1}},wo={initial:{y:-100,rotate:-90,opacity:0},visible:{y:0,rotate:0,opacity:1}},Eo={initial:{y:100,rotate:90,opacity:0},enter:{y:0,rotate:0,opacity:1}},Oo={initial:{y:100,rotate:90,opacity:0},visible:{y:0,rotate:0,opacity:1}},No={initial:{x:-100,opacity:0},enter:{x:0,opacity:1}},Vo={initial:{x:-100,opacity:0},visible:{x:0,opacity:1}},ko={initial:{x:100,opacity:0},enter:{x:0,opacity:1}},xo={initial:{x:100,opacity:0},visible:{x:0,opacity:1}},Ro={initial:{y:-100,opacity:0},enter:{y:0,opacity:1}},So={initial:{y:-100,opacity:0},visible:{y:0,opacity:1}},Co={initial:{y:100,opacity:0},enter:{y:0,opacity:1}},jo={initial:{y:100,opacity:0},visible:{y:0,opacity:1}};var $o=Object.freeze({__proto__:null,fade:po,fadeVisible:fo,pop:vo,popVisible:ho,rollBottom:Eo,rollLeft:yo,rollRight:mo,rollTop:_o,rollVisibleBottom:Oo,rollVisibleLeft:go,rollVisibleRight:bo,rollVisibleTop:wo,slideBottom:Co,slideLeft:No,slideRight:ko,slideTop:Ro,slideVisibleBottom:jo,slideVisibleLeft:Vo,slideVisibleRight:xo,slideVisibleTop:So});function Do(e){const t="àáâäæãåāăąçćčđďèéêëēėęěğǵḧîïíīįìłḿñńǹňôöòóœøōõőṕŕřßśšşșťțûüùúūǘůűųẃẍÿýžźż·/_,:;",n=new RegExp(t.split("").join("|"),"g");return e.toString().replace(/[A-Z]/g,(e=>"-"+e)).toLowerCase().replace(/\s+/g,"-").replace(n,(e=>"aaaaaaaaaacccddeeeeeeeegghiiiiiilmnnnnoooooooooprrsssssttuuuuuuuuuwxyyzzz------".charAt(t.indexOf(e)))).replace(/&/g,"-and-").replace(/[^\w\-]+/g,"").replace(/\-\-+/g,"-").replace(/^-+/,"").replace(/-+$/,"")}const Io={install(e,t){if(e.directive("motion",uo()),!t||t&&!t.excludePresets)for(const t in $o){const n=$o[t];e.directive(`motion-${Do(t)}`,uo(n))}if(t&&t.directives)for(const n in t.directives){const o=t.directives[n];0,e.directive(`motion-${n}`,uo(o))}}};return e.MotionDirective=uo,e.MotionPlugin=Io,e.fade=po,e.fadeVisible=fo,e.pop=vo,e.popVisible=ho,e.reactiveStyle=qn,e.reactiveTransform=eo,e.rollBottom=Eo,e.rollLeft=yo,e.rollRight=mo,e.rollTop=_o,e.rollVisibleBottom=Oo,e.rollVisibleLeft=go,e.rollVisibleRight=bo,e.rollVisibleTop=wo,e.slideBottom=Co,e.slideLeft=No,e.slideRight=ko,e.slideTop=Ro,e.slideVisibleBottom=jo,e.slideVisibleLeft=Vo,e.slideVisibleRight=xo,e.slideVisibleTop=So,e.slugify=Do,e.useElementStyle=Gn,e.useElementTransform=to,e.useMotion=co,e.useMotionControls=cn,e.useMotionProperties=io,e.useMotionTransitions=an,e.useMotionVariants=ao,e.useMotions=function(){return r},Object.defineProperty(e,"__esModule",{value:!0}),e}({},VueDemi,VueUse,popmotion); | ||
***************************************************************************** */var dn=function(){return(dn=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)},vn=function(e,t){return function(n){return Math.max(Math.min(n,t),e)}},hn=function(e){return e%1?Number(e.toFixed(5)):e},yn=/(-)?([\d]*\.?[\d])+/g,gn=/(#[0-9a-f]{6}|#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))/gi,mn=/^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))$/i;function bn(e){return"string"==typeof e}var _n={test:function(e){return"number"==typeof e},parse:parseFloat,transform:function(e){return e}},wn=dn(dn({},_n),{transform:vn(0,1)}),En=dn(dn({},_n),{default:1}),On=function(e){return{test:function(t){return bn(t)&&t.endsWith(e)&&1===t.split(" ").length},parse:parseFloat,transform:function(t){return""+t+e}}},Nn=On("deg"),Vn=On("%"),kn=On("px"),xn=dn(dn({},Vn),{parse:function(e){return Vn.parse(e)/100},transform:function(e){return Vn.transform(100*e)}}),Rn=function(e,t){return function(n){return bn(n)&&mn.test(n)&&n.startsWith(e)||t&&Object.prototype.hasOwnProperty.call(n,t)}},Sn=function(e,t,n){return function(o){var r;if(!bn(o))return o;var s=o.match(yn),i=s[1],a=s[2],c=s[3];return(r={})[e]=parseFloat(s[0]),r[t]=parseFloat(i),r[n]=parseFloat(a),r.alpha=void 0!==c?parseFloat(c):1,r}},Cn={test:Rn("hsl","hue"),parse:Sn("hue","saturation","lightness"),transform:function(e){var t=e.saturation,n=e.lightness,o=e.alpha,r=void 0===o?1:o;return"hsla("+Math.round(e.hue)+", "+Vn.transform(hn(t))+", "+Vn.transform(hn(n))+", "+hn(wn.transform(r))+")"}},jn=vn(0,255),$n=dn(dn({},_n),{transform:function(e){return Math.round(jn(e))}}),Dn={test:Rn("rgb","red"),parse:Sn("red","green","blue"),transform:function(e){var t=e.green,n=e.blue,o=e.alpha,r=void 0===o?1:o;return"rgba("+$n.transform(e.red)+", "+$n.transform(t)+", "+$n.transform(n)+", "+hn(wn.transform(r))+")"}};var In={test:Rn("#"),parse:function(e){var t="",n="",o="",r="";return e.length>5?(t=e.substr(1,2),n=e.substr(3,2),o=e.substr(5,2),r=e.substr(7,2)):(t=e.substr(1,1),n=e.substr(2,1),o=e.substr(3,1),r=e.substr(4,1),t+=t,n+=n,o+=o,r+=r),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(o,16),alpha:r?parseInt(r,16)/255:1}},transform:Dn.transform},Tn={test:function(e){return Dn.test(e)||In.test(e)||Cn.test(e)},parse:function(e){return Dn.test(e)?Dn.parse(e):Cn.test(e)?Cn.parse(e):In.parse(e)},transform:function(e){return bn(e)?e:e.hasOwnProperty("red")?Dn.transform(e):Cn.transform(e)}},Pn="${c}",Mn="${n}";function An(e){var t=[],n=0,o=e.match(gn);o&&(n=o.length,e=e.replace(gn,Pn),t.push.apply(t,o.map(Tn.parse)));var r=e.match(yn);return r&&(e=e.replace(yn,Mn),t.push.apply(t,r.map(_n.parse))),{values:t,numColors:n,tokenised:e}}function Fn(e){return An(e).values}function Ln(e){var t=An(e),n=t.numColors,o=t.tokenised,r=t.values.length;return function(e){for(var t=o,s=0;s<r;s++)t=t.replace(s<n?Pn:Mn,s<n?Tn.transform(e[s]):hn(e[s]));return t}}var zn=function(e){return"number"==typeof e?0:e};var Un={test:function(e){var t,n,o,r;return isNaN(e)&&bn(e)&&(null!==(n=null===(t=e.match(yn))||void 0===t?void 0:t.length)&&void 0!==n?n:0)+(null!==(r=null===(o=e.match(gn))||void 0===o?void 0:o.length)&&void 0!==r?r:0)>0},parse:Fn,createTransformer:Ln,getAnimatableNone:function(e){var t=Fn(e);return Ln(e)(t.map(zn))}},Bn=new Set(["brightness","contrast","saturate","opacity"]);function Wn(e){var t=e.slice(0,-1).split("("),n=t[0],o=t[1];if("drop-shadow"===n)return e;var r=(o.match(yn)||[])[0];if(!r)return e;var s=o.replace(r,""),i=Bn.has(n)?1:0;return r!==o&&(i*=100),n+"("+i+s+")"}var Hn=/([a-z-]*)\(.*?\)/g,Zn=dn(dn({},Un),{getAnimatableNone:function(e){var t=e.match(Hn);return t?t.map(Wn).join(" "):e}});const Xn={..._n,transform:Math.round},Yn={color:Tn,backgroundColor:Tn,outlineColor:Tn,fill:Tn,stroke:Tn,borderColor:Tn,borderTopColor:Tn,borderRightColor:Tn,borderBottomColor:Tn,borderLeftColor:Tn,borderWidth:kn,borderTopWidth:kn,borderRightWidth:kn,borderBottomWidth:kn,borderLeftWidth:kn,borderRadius:kn,radius:kn,borderTopLeftRadius:kn,borderTopRightRadius:kn,borderBottomRightRadius:kn,borderBottomLeftRadius:kn,width:kn,maxWidth:kn,height:kn,maxHeight:kn,size:kn,top:kn,right:kn,bottom:kn,left:kn,padding:kn,paddingTop:kn,paddingRight:kn,paddingBottom:kn,paddingLeft:kn,margin:kn,marginTop:kn,marginRight:kn,marginBottom:kn,marginLeft:kn,rotate:Nn,rotateX:Nn,rotateY:Nn,rotateZ:Nn,scale:En,scaleX:En,scaleY:En,scaleZ:En,skew:Nn,skewX:Nn,skewY:Nn,distance:kn,translateX:kn,translateY:kn,translateZ:kn,x:kn,y:kn,z:kn,perspective:kn,transformPerspective:kn,opacity:wn,originX:xn,originY:xn,originZ:kn,zIndex:Xn,filter:Zn,WebkitFilter:Zn,fillOpacity:wn,strokeOpacity:wn,numOctaves:Xn},Jn=e=>Yn[e],Kn=(e,t)=>t&&"number"==typeof e&&t.transform?t.transform(e):e;function qn(e={}){const n=t.reactive({...e}),o=t.computed((()=>{const e={};for(const[t,o]of Object.entries(n)){const n=Jn(t),r=Kn(o,n);e[t]=r}return e}));return{state:n,style:o}}function Gn(e){const n=t.ref(e);let o;const{state:r,style:s}=qn(),i=t.watch(n,(e=>{if(e){for(const t of Object.keys(Yn))null!=e.style[t]&&""!==e.style[t]&&(r[t]=e.style[t]);o&&Object.assign(e.style,o)}})),a=t.watch(s,(e=>{n.value&&n.value.style?Object.assign(n.value.style,e):o=e}),{immediate:!0});return{style:r,stop:()=>{i(),a()}}}const Qn={x:"translateX",y:"translateY",z:"translateZ"};function eo(e={},n=!0){const o=t.reactive({...e}),r=t.computed((()=>{let e="",t=!1;for(const[n,r]of Object.entries(o)){const o=Jn(n),s=Kn(r,o);e+=`${Qn[n]||n}(${s}) `,"z"!==n&&"translateZ"!==n||(t=!0)}return!t&&n?e+="translateZ(0)":e=e.trim(),e}));return{state:o,transform:r}}function to(e){const n=t.ref(e);let o;const{state:r,transform:s}=eo(),i=t.watch(n,(e=>{e&&o&&(e.style.transform=o)})),a=t.watch(s,(e=>{n.value&&n.value.style?n.value.style.transform=e:o=e}),{immediate:!0});return{transform:r,stop:()=>{i(),a()}}}const no=["","X","Y","Z"],oo=["transformPerspective","x","y","z"];["perspective","translate","scale","rotate","skew"].forEach((e=>{no.forEach((t=>{oo.push(e+t)}))}));const ro=new Set(oo);function so(e){return ro.has(e)}function io(e){const n=t.ref(e),{style:o}=Gn(n),{transform:r}=to(n),s=t.reactive({});return t.watch(s,(e=>{for(const t in e){const n=so(t)?r:o;n[t]&&n[t]===e[t]||(n[t]=e[t])}}),{immediate:!0,deep:!0}),{motionProperties:s,style:o,transform:r}}function ao(e={}){const n=t.ref(e),o=t.ref();return{state:t.computed((()=>{if(o.value)return n.value[o.value]})),variant:o}}function co(e,n={},o){const r=t.ref(n),s=t.ref(e),{motionProperties:i}=io(s),{variant:a,state:c}=ao(r),l={target:s,variant:a,variants:r,state:c,motionProperties:i,...cn(i,r)};return fn(l,o),l}const lo=["initial","enter","leave","visible","hovered","tapped","focused","delay"],uo=e=>{const o=(o,s,i)=>{const a=t.ref(e||{});((e,t)=>{const o=e.props?e.props:e.data&&e.data.attrs?e.data.attrs:{};o&&(o.variants&&n.isObject(o.variants)&&(t.value={...t.value,...o.variants}),lo.forEach((e=>{if("delay"!==e)o&&o[e]&&n.isObject(o[e])&&(t.value[e]=o[e]);else if(o&&o[e]&&n.isNumber(o[e])){const n=o[e];t&&t.value&&(t.value.enter&&(t.value.enter.transition||(t.value.enter.transition={}),t.value.enter.transition={...t.value.enter.transition,delay:n}),t.value.visible&&(t.value.visible.transition||(t.value.visible.transition={}),t.value.visible.transition={...t.value.visible.transition,delay:n}))}})))})(i,a);const c=co(o,a);s.value&&(r[s.value]=c)},s=(e,t,n)=>{t.value&&r[t.value]&&delete r[t.value]};return{created:o,unmounted:s,bind:o,unbind:s}},po={initial:{opacity:0},enter:{opacity:1}},fo={initial:{opacity:0},visible:{opacity:1}},vo={initial:{scale:0,opacity:0},enter:{scale:1,opacity:1}},ho={initial:{scale:0,opacity:0},visible:{scale:1,opacity:1}},yo={initial:{x:-100,rotate:90,opacity:0},enter:{x:0,rotate:0,opacity:1}},go={initial:{x:-100,rotate:90,opacity:0},visible:{x:0,rotate:0,opacity:1}},mo={initial:{x:100,rotate:-90,opacity:0},enter:{x:0,rotate:0,opacity:1}},bo={initial:{x:100,rotate:-90,opacity:0},visible:{x:0,rotate:0,opacity:1}},_o={initial:{y:-100,rotate:-90,opacity:0},enter:{y:0,rotate:0,opacity:1}},wo={initial:{y:-100,rotate:-90,opacity:0},visible:{y:0,rotate:0,opacity:1}},Eo={initial:{y:100,rotate:90,opacity:0},enter:{y:0,rotate:0,opacity:1}},Oo={initial:{y:100,rotate:90,opacity:0},visible:{y:0,rotate:0,opacity:1}},No={initial:{x:-100,opacity:0},enter:{x:0,opacity:1}},Vo={initial:{x:-100,opacity:0},visible:{x:0,opacity:1}},ko={initial:{x:100,opacity:0},enter:{x:0,opacity:1}},xo={initial:{x:100,opacity:0},visible:{x:0,opacity:1}},Ro={initial:{y:-100,opacity:0},enter:{y:0,opacity:1}},So={initial:{y:-100,opacity:0},visible:{y:0,opacity:1}},Co={initial:{y:100,opacity:0},enter:{y:0,opacity:1}},jo={initial:{y:100,opacity:0},visible:{y:0,opacity:1}};var $o=Object.freeze({__proto__:null,fade:po,fadeVisible:fo,pop:vo,popVisible:ho,rollBottom:Eo,rollLeft:yo,rollRight:mo,rollTop:_o,rollVisibleBottom:Oo,rollVisibleLeft:go,rollVisibleRight:bo,rollVisibleTop:wo,slideBottom:Co,slideLeft:No,slideRight:ko,slideTop:Ro,slideVisibleBottom:jo,slideVisibleLeft:Vo,slideVisibleRight:xo,slideVisibleTop:So});function Do(e){const t="àáâäæãåāăąçćčđďèéêëēėęěğǵḧîïíīįìłḿñńǹňôöòóœøōõőṕŕřßśšşșťțûüùúūǘůűųẃẍÿýžźż·/_,:;",n=new RegExp(t.split("").join("|"),"g");return e.toString().replace(/[A-Z]/g,(e=>"-"+e)).toLowerCase().replace(/\s+/g,"-").replace(n,(e=>"aaaaaaaaaacccddeeeeeeeegghiiiiiilmnnnnoooooooooprrsssssttuuuuuuuuuwxyyzzz------".charAt(t.indexOf(e)))).replace(/&/g,"-and-").replace(/[^\w\-]+/g,"").replace(/\-\-+/g,"-").replace(/^-+/,"").replace(/-+$/,"")}const Io={install(e,t){if(e.directive("motion",uo()),!t||t&&!t.excludePresets)for(const t in $o){const n=$o[t];e.directive(`motion-${Do(t)}`,uo(n))}if(t&&t.directives)for(const n in t.directives){const o=t.directives[n];0,e.directive(`motion-${n}`,uo(o))}}};return e.MotionDirective=uo,e.MotionPlugin=Io,e.fade=po,e.fadeVisible=fo,e.pop=vo,e.popVisible=ho,e.reactiveStyle=qn,e.reactiveTransform=eo,e.rollBottom=Eo,e.rollLeft=yo,e.rollRight=mo,e.rollTop=_o,e.rollVisibleBottom=Oo,e.rollVisibleLeft=go,e.rollVisibleRight=bo,e.rollVisibleTop=wo,e.slideBottom=Co,e.slideLeft=No,e.slideRight=ko,e.slideTop=Ro,e.slideVisibleBottom=jo,e.slideVisibleLeft=Vo,e.slideVisibleRight=xo,e.slideVisibleTop=So,e.slugify=Do,e.useElementStyle=Gn,e.useElementTransform=to,e.useMotion=co,e.useMotionControls=cn,e.useMotionProperties=io,e.useMotionTransitions=an,e.useMotionVariants=ao,e.useMotions=function(){return r},Object.defineProperty(e,"__esModule",{value:!0}),e}({},VueDemi,VueUse,popmotion); |
{ | ||
"name": "@vueuse/motion", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "🤹 Vue Composables putting your components in motion", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/vueuse/motion", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
987741
20975