motion-plus-vue 0.0.1 → 0.0.2
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/cjs/index.js +2 -2
- package/dist/components/Cursor/Cursor.d.ts +5 -5
- package/dist/components/Cursor/hooks/use-snap-to-target.d.ts +2 -2
- package/dist/es/components/AnimateNumber/NumberDigit.vue.mjs +22 -21
- package/dist/es/components/AnimateNumber/NumberSymbol.vue.mjs +11 -10
- package/dist/es/components/Cursor/hooks/use-cursor-in-view.mjs +16 -19
- package/dist/es/components/Cursor/hooks/use-cursor-state/index.mjs +28 -31
- package/dist/es/components/Cursor/use-cursor-styles.mjs +10 -15
- package/package.json +3 -3
package/dist/cjs/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),u=require("motion-v");function K(n,{locales:t,format:i},a,s){const h=new Intl.NumberFormat(t,i).formatToParts(Number(n));a&&h.unshift({type:"prefix",value:a}),s&&h.push({type:"suffix",value:s});const p=[],m=[],x=[],f=[],v={},o=l=>`${l}:${v[l]=(v[l]??-1)+1}`;let d="",w=!1,C=!1,y=0;for(const l of h){d+=l.value;const g=l.type==="minusSign"||l.type==="plusSign"?"sign":l.type;switch(g){case"integer":w=!0,m.push(...l.value.split("").map(B=>({type:g,value:parseInt(B)})));break;case"group":m.push({type:g,value:l.value});break;case"decimal":C=!0,x.push({type:g,value:l.value,key:o(g),originalIndex:y++});break;case"fraction":x.push(...l.value.split("").map(B=>({type:g,value:parseInt(B),key:o(g),originalIndex:y++})));break;default:(w||C?f:p).push({type:g,value:l.value,key:o(g),originalIndex:y++})}}const c=[];for(let l=m.length-1;l>=0;l--){const g=o(m[l].type);c.unshift({...m[l],key:g,originalIndex:l})}return{pre:p,integer:c,fraction:x,post:f,formatted:d}}const[G,U]=u.createContext("SectionContext");function O(){const n={current:!0};return e.onMounted(()=>{n.current=!1}),n}function z(n){const{width:t,fontSize:i}=getComputedStyle(n);return`${parseFloat(t)/parseFloat(i)}em`}const k="var(--mask-height, 0.15em)",E="var(--mask-width, 0.5em)",P=`calc(${E} / var(--invert-x, 1))`,b="#000 0, transparent 71%",q=`linear-gradient(to right, transparent 0, #000 ${P}, #000 calc(100% - ${P}), transparent),linear-gradient(to bottom, transparent 0, #000 ${k}, #000 calc(100% - ${k}), transparent 100%),radial-gradient(at bottom right, ${b}),radial-gradient(at bottom left, ${b}), radial-gradient(at top left, ${b}), radial-gradient(at top right, ${b})`,Z=`100% calc(100% - ${k} * 2),calc(100% - ${P} * 2) 100%,${P} ${k},${P} ${k},${P} ${k},${P} ${k}`;u.addScaleCorrector({"--invert-x":{correct:(n,{treeScale:t,projectionDelta:i})=>i.x.scale*t.x}});const M={display:"flex",flexDirection:"column",alignItems:"center",position:"absolute",width:"100%"};function W(n){const t=e.ref();function i(s){t.value=s==null?void 0:s.$el}e.watch(()=>n.isPresent,s=>{var r;t.value&&((r=u.mountedStates.get(t.value))==null||r.setActive("exit",!s))});function a(s){var r;s.detail.isExit&&!n.isPresent&&((r=n.onRemove)==null||r.call(n,n.partKey))}return{root:t,getRoot:i,handleComplete:a}}const J=e.defineComponent({__name:"NumberSymbol",props:{partKey:{},type:{},value:{},isPresent:{type:Boolean},onRemove:{type:Function},style:{}},setup(n){const t=n,{justify:i}=G(),{getRoot:a,handleComplete:s}=W(t);return(r,h)=>(e.openBlock(),e.createBlock(e.unref(u.motion).span,{ref:e.unref(a),layout:"position","data-state":r.isPresent?void 0:"exiting",style:e.normalizeStyle({display:"inline-flex",justifyContent:e.unref(i),padding:`calc(${e.unref(k)}/2) 0`,position:"relative"}),"aria-hidden":!r.isPresent,onMotioncomplete:e.unref(s)},{default:e.withCtx(()=>[e.createVNode(e.unref(u.AnimatePresence),{multiple:"",mode:"popLayout","anchor-x":e.unref(i),initial:!1},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.unref(u.motion).span,{key:r.value,layout:e.unref(i)==="right"?"position":!1,initial:{opacity:0},animate:{opacity:[null,1]},exit:{opacity:[null,0],transition:{duration:.3}},style:{display:"inline-block",whiteSpace:"pre"},transition:{duration:.2}},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(r.value),1)]),_:1},8,["layout"]))]),_:1},8,["anchor-x"])]),_:1},8,["data-state","style","aria-hidden","onMotioncomplete"]))}}),X=new WeakMap,Q=e.defineComponent({__name:"NumberDigit",props:{value:{},initialValue:{default:void 0},isPresent:{type:Boolean},partKey:{},onRemove:{},style:{}},setup(n){const t=n,i=t.initialValue??t.value,a=O(),s=u.useMotionConfig(),r=e.ref(),h=e.ref(Array(10).fill(null)),p=e.ref(),{getRoot:m,handleComplete:x,root:f}=W(t);let v=i;const o=e.ref(i);e.watch([()=>t.value,()=>t.isPresent],([y,c])=>{if(!c)return o.value=0;if(a.current)return e.nextTick(()=>{o.value=y});o.value=y},{immediate:!0});function d(y){var B;if(!r.value||y===v)return;const c=r.value.getBoundingClientRect(),l=(B=f.value)==null?void 0:B.getBoundingClientRect(),g=c.height*(y-v)+(c.top-(l?l.top||0:c.top));u.animate(r.value,{y:[g,0]},s.value.transition)}function w(y){if(a.current&&i===y||!h.value[y])return;const c=z(h.value[y]);f.value&&X.set(f.value,c),p.value=c}e.watch(o,y=>{w(y)},{immediate:!0,flush:"post"}),e.watch(o,(y,c,l)=>{d(y),l(()=>{v=y})},{immediate:!0,flush:"pre"});function C(y){return()=>e.createVNode("span",{key:y,style:{display:"inline-block",padding:`calc(${k}/2) 0`}},[y])}return(y,c)=>(e.openBlock(),e.createBlock(e.unref(u.motion).span,{ref:e.unref(m),layout:"position","data-state":y.isPresent?void 0:"exiting","data-key":y.partKey,style:e.normalizeStyle({display:"inline-flex",justifyContent:"center",width:p.value}),"aria-hidden":!y.isPresent,onMotioncomplete:e.unref(x)},{default:e.withCtx(()=>[e.createElementVNode("span",{ref_key:"scope",ref:r,style:{display:"inline-flex",justifyContent:"center",flexDirection:"column",alignItems:"center",position:"relative"}},[o.value!==0?(e.openBlock(),e.createElementBlock("span",{key:0,style:e.normalizeStyle({...e.unref(M),bottom:"100%",left:0})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,l=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(C(l-1)),{key:l-1}))),128))],4)):e.createCommentVNode("",!0),(e.openBlock(),e.createBlock(e.resolveDynamicComponent(C(o.value)))),o.value!==9?(e.openBlock(),e.createElementBlock("span",{key:1,style:e.normalizeStyle({...e.unref(M),top:"100%",left:0})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(9-o.value,l=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(C(o.value+l)),{key:o.value+l}))),128))],4)):e.createCommentVNode("",!0)],512)]),_:1},8,["data-state","data-key","style","aria-hidden","onMotioncomplete"]))}}),$=e.defineComponent({__name:"NumberSection",props:{parts:{},justify:{default:"left"},mode:{},name:{},style:{}},setup(n){const t=n,i=e.ref(),a=e.ref();function s(f){a.value=f==null?void 0:f.$el}const r=e.ref(),h=O();e.watch(()=>t.parts.map(f=>f.value).join(""),()=>{if(!r.value)return;if(h.current){a.value&&(a.value.style.width=z(r.value));return}const f=Array.from(r.value.children).map(o=>{if(!(o instanceof HTMLElement))return;if(o.dataset.state==="exiting"){const C=o.nextSibling;return o.remove(),()=>{r.value&&r.value.insertBefore(o,C)}}const d=X.get(o);if(!d)return;const w=o.style.width;return o.style.width=d,()=>{o.style.width=w}}),v=z(r.value);i.value=v;for(let o=f.length-1;o>=0;o--){const d=f[o];d&&d()}},{immediate:!0,flush:"post"});const p=e.toRef(t,"justify");U({justify:p});let m=t.parts;e.watch(()=>t.parts,f=>{const v=new Map(f.map(d=>[d.key,{...d,isPresent:!0}]));m=[...m.filter(d=>!v.get(d.key)).map(d=>({...d,isPresent:!1})),...f].sort((d,w)=>p.value==="right"?d.isPresent===w.isPresent?d.originalIndex-w.originalIndex:d.isPresent?-1:1:p.value==="left"?d.isPresent===w.isPresent?d.originalIndex-w.originalIndex:d.isPresent?1:-1:d.originalIndex-w.originalIndex)});function x(f){m=m.filter(v=>v.key!==f)}return(f,v)=>(e.openBlock(),e.createBlock(e.unref(u.motion).span,{ref:s,class:e.normalizeClass(`number-section-${f.name}`),style:e.normalizeStyle({...f.style,display:"inline-flex",justifyContent:p.value,width:i.value}),layout:"position"},{default:e.withCtx(()=>[e.createElementVNode("span",{ref_key:"measuredRef",ref:r,style:{display:"inline-flex",justifyContent:"inherit",position:"relative"}},[v[0]||(v[0]=e.createTextVNode(" ")),e.createVNode(e.unref(u.AnimatePresence),{multiple:"",mode:f.mode,"anchor-x":p.value,initial:!1},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(m),o=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:o.key},[o.type==="integer"||o.type==="fraction"?(e.openBlock(),e.createBlock(Q,{key:o.key,"part-key":o.key,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},value:o.value,"is-present":o.isPresent??!0,"initial-value":e.unref(h).current?void 0:0,onRemove:x},null,8,["part-key","value","is-present","initial-value"])):(e.openBlock(),e.createBlock(J,{key:o.type==="literal"?`${o.key}:${o.value}`:o.key,type:o.type,"part-key":o.key,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},value:o.value,"is-present":o.isPresent??!0,onRemove:x},null,8,["type","part-key","value","is-present"]))],64))),128))]),_:1},8,["mode","anchor-x"])],512)]),_:1},8,["class","style"]))}}),ee=e.defineComponent({__name:"Mask",setup(n){return(t,i)=>(e.openBlock(),e.createBlock(e.unref(u.motion).span,{layout:"","aria-hidden":!0,style:e.normalizeStyle({display:"inline-flex","--invert-x":1,margin:`0 calc(-1*${e.unref(E)})`,padding:`calc(${e.unref(k)}/2) ${e.unref(E)}`,position:"relative",zIndex:-1,overflow:"clip",webkitMaskImage:e.unref(q),webkitMaskSize:e.unref(Z),webkitMaskPosition:"center, center, top left, top right, bottom right, bottom left",webkitMaskRepeat:"no-repeat"})},{default:e.withCtx(()=>[e.renderSlot(t.$slots,"default")]),_:3},8,["style"]))}}),te=e.defineComponent({name:"AnimateNumber",__name:"AnimateNumber",props:{locales:{},format:{},transition:{},suffix:{},prefix:{},value:{},style:{}},setup(n){const t={opacity:{duration:1,ease:u.easeOut},layout:{type:"spring",duration:1,bounce:0},y:{type:"spring",duration:1,bounce:0}},i=n,a=e.computed(()=>{const p=i.value;return K(p,{locales:i.locales,format:i.format},i.prefix,i.suffix)}),s=u.useMotionConfig(),r=e.computed(()=>i.transition??s.value.transition??t);function h(){const{format:p,prefix:m,suffix:x,locales:f,value:v,...o}=i;return o}return(p,m)=>(e.openBlock(),e.createBlock(e.unref(u.LayoutGroup),null,{default:e.withCtx(()=>[e.createVNode(e.unref(u.MotionConfig),{transition:r.value},{default:e.withCtx(()=>[e.createVNode(e.unref(u.motion).div,e.mergeProps({...p.$attrs,...h()},{layout:"",style:{lineHeight:"1",...p.style,display:"inline-flex",isolation:"isolate",whiteSpace:"nowrap"}}),{default:e.withCtx(()=>[e.createVNode(e.unref(u.motion).div,{layout:"","aria-label":a.value.formatted,style:{display:"inline-flex",direction:"ltr",isolation:"isolate",position:"relative",zIndex:-1}},{default:e.withCtx(()=>[e.createVNode($,{style:e.normalizeStyle({padding:`calc(${e.unref(k)}/2) 0`}),"aria-hidden":!0,justify:"right",mode:"popLayout",parts:a.value.pre,name:"pre"},null,8,["style","parts"]),e.createVNode(ee,null,{default:e.withCtx(()=>[e.createVNode($,{justify:"right",parts:a.value.integer,name:"integer",mode:"popLayout"},null,8,["parts"]),e.createVNode($,{layout:"position",parts:a.value.fraction,name:"fraction",mode:"popLayout"},null,8,["parts"])]),_:1}),e.createVNode($,{style:e.normalizeStyle({padding:`calc(${e.unref(k)}/2) 0`}),"aria-hidden":!0,layout:"position",mode:"popLayout",parts:a.value.post,name:"post"},null,8,["style","parts"])]),_:1},8,["aria-label"])]),_:1},16,["style"])]),_:1},8,["transition"])]),_:1}))}}),ne=te;function oe(){const n=document.createElement("style");return n.textContent=`
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),u=require("motion-v");function K(n,{locales:t,format:i},a,l){const h=new Intl.NumberFormat(t,i).formatToParts(Number(n));a&&h.unshift({type:"prefix",value:a}),l&&h.push({type:"suffix",value:l});const p=[],m=[],x=[],f=[],v={},o=s=>`${s}:${v[s]=(v[s]??-1)+1}`;let d="",w=!1,C=!1,y=0;for(const s of h){d+=s.value;const g=s.type==="minusSign"||s.type==="plusSign"?"sign":s.type;switch(g){case"integer":w=!0,m.push(...s.value.split("").map(B=>({type:g,value:parseInt(B)})));break;case"group":m.push({type:g,value:s.value});break;case"decimal":C=!0,x.push({type:g,value:s.value,key:o(g),originalIndex:y++});break;case"fraction":x.push(...s.value.split("").map(B=>({type:g,value:parseInt(B),key:o(g),originalIndex:y++})));break;default:(w||C?f:p).push({type:g,value:s.value,key:o(g),originalIndex:y++})}}const c=[];for(let s=m.length-1;s>=0;s--){const g=o(m[s].type);c.unshift({...m[s],key:g,originalIndex:s})}return{pre:p,integer:c,fraction:x,post:f,formatted:d}}const[G,U]=u.createContext("SectionContext");function O(){const n={current:!0};return e.onMounted(()=>{n.current=!1}),n}function z(n){const{width:t,fontSize:i}=getComputedStyle(n);return`${parseFloat(t)/parseFloat(i)}em`}const k="var(--mask-height, 0.15em)",_="var(--mask-width, 0.5em)",P=`calc(${_} / var(--invert-x, 1))`,b="#000 0, transparent 71%",q=`linear-gradient(to right, transparent 0, #000 ${P}, #000 calc(100% - ${P}), transparent),linear-gradient(to bottom, transparent 0, #000 ${k}, #000 calc(100% - ${k}), transparent 100%),radial-gradient(at bottom right, ${b}),radial-gradient(at bottom left, ${b}), radial-gradient(at top left, ${b}), radial-gradient(at top right, ${b})`,Z=`100% calc(100% - ${k} * 2),calc(100% - ${P} * 2) 100%,${P} ${k},${P} ${k},${P} ${k},${P} ${k}`;u.addScaleCorrector({"--invert-x":{correct:(n,{treeScale:t,projectionDelta:i})=>i.x.scale*t.x}});const M={display:"flex",flexDirection:"column",alignItems:"center",position:"absolute",width:"100%"};function W(n){const t=e.ref();function i(l){t.value=l==null?void 0:l.$el}e.watch(()=>n.isPresent,l=>{var r;t.value&&((r=u.mountedStates.get(t.value))==null||r.setActive("exit",!l))});function a(l){var r;l.detail.isExit&&!n.isPresent&&((r=n.onRemove)==null||r.call(n,n.partKey))}return{root:t,getRoot:i,handleComplete:a}}const J=e.defineComponent({__name:"NumberSymbol",props:{partKey:{},type:{},value:{},isPresent:{type:Boolean},onRemove:{type:Function},style:{}},setup(n){const t=n,{justify:i}=G(),{getRoot:a,handleComplete:l}=W(t);return(r,h)=>(e.openBlock(),e.createBlock(e.unref(u.motion).span,{ref:e.unref(a),layout:"position","data-state":r.isPresent?void 0:"exiting",style:e.normalizeStyle({display:"inline-flex",justifyContent:e.unref(i),padding:`calc(${e.unref(k)}/2) 0`,position:"relative",pointerEvents:r.isPresent?void 0:"none"}),"aria-hidden":!r.isPresent,onMotioncomplete:e.unref(l)},{default:e.withCtx(()=>[e.createVNode(e.unref(u.AnimatePresence),{multiple:"",mode:"popLayout","anchor-x":e.unref(i),initial:!1},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.unref(u.motion).span,{key:r.value,layout:e.unref(i)==="right"?"position":!1,initial:{opacity:0},animate:{opacity:[null,1]},exit:{opacity:[null,0],transition:{duration:.3}},style:{display:"inline-block",whiteSpace:"pre"},transition:{duration:.2}},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(r.value),1)]),_:1},8,["layout"]))]),_:1},8,["anchor-x"])]),_:1},8,["data-state","style","aria-hidden","onMotioncomplete"]))}}),X=new WeakMap,Q=e.defineComponent({__name:"NumberDigit",props:{value:{},initialValue:{default:void 0},isPresent:{type:Boolean},partKey:{},onRemove:{},style:{}},setup(n){const t=n,i=t.initialValue??t.value,a=O(),l=u.useMotionConfig(),r=e.ref(),h=e.ref(Array(10).fill(null)),p=e.ref(),{getRoot:m,handleComplete:x,root:f}=W(t);let v=i;const o=e.ref(i);e.watch([()=>t.value,()=>t.isPresent],([y,c])=>{if(!c)return o.value=0;if(a.current)return e.nextTick(()=>{o.value=y});o.value=y},{immediate:!0});function d(y){var B;if(!r.value||y===v)return;const c=r.value.getBoundingClientRect(),s=(B=f.value)==null?void 0:B.getBoundingClientRect(),g=c.height*(y-v)+(c.top-(s?s.top||0:c.top));u.animate(r.value,{y:[g,0]},l.value.transition)}function w(y){if(a.current&&i===y||!h.value[y])return;const c=z(h.value[y]);f.value&&X.set(f.value,c),p.value=c}e.watch(o,y=>{w(y)},{immediate:!0,flush:"post"}),e.watch(o,(y,c,s)=>{d(y),s(()=>{v=y})},{immediate:!0,flush:"pre"});function C(y){return()=>e.createVNode("span",{key:y,style:{display:"inline-block",padding:`calc(${k}/2) 0`}},[y])}return(y,c)=>(e.openBlock(),e.createBlock(e.unref(u.motion).span,{ref:e.unref(m),layout:"position","data-state":y.isPresent?void 0:"exiting","data-key":y.partKey,style:e.normalizeStyle({display:"inline-flex",justifyContent:"center",width:p.value,pointerEvents:y.isPresent?void 0:"none"}),"aria-hidden":!y.isPresent,onMotioncomplete:e.unref(x)},{default:e.withCtx(()=>[e.createElementVNode("span",{ref_key:"scope",ref:r,style:{display:"inline-flex",justifyContent:"center",flexDirection:"column",alignItems:"center",position:"relative"}},[o.value!==0?(e.openBlock(),e.createElementBlock("span",{key:0,style:e.normalizeStyle({...e.unref(M),bottom:"100%",left:0})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,s=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(C(s-1)),{key:s-1}))),128))],4)):e.createCommentVNode("",!0),(e.openBlock(),e.createBlock(e.resolveDynamicComponent(C(o.value)))),o.value!==9?(e.openBlock(),e.createElementBlock("span",{key:1,style:e.normalizeStyle({...e.unref(M),top:"100%",left:0})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(9-o.value,s=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(C(o.value+s)),{key:o.value+s}))),128))],4)):e.createCommentVNode("",!0)],512)]),_:1},8,["data-state","data-key","style","aria-hidden","onMotioncomplete"]))}}),$=e.defineComponent({__name:"NumberSection",props:{parts:{},justify:{default:"left"},mode:{},name:{},style:{}},setup(n){const t=n,i=e.ref(),a=e.ref();function l(f){a.value=f==null?void 0:f.$el}const r=e.ref(),h=O();e.watch(()=>t.parts.map(f=>f.value).join(""),()=>{if(!r.value)return;if(h.current){a.value&&(a.value.style.width=z(r.value));return}const f=Array.from(r.value.children).map(o=>{if(!(o instanceof HTMLElement))return;if(o.dataset.state==="exiting"){const C=o.nextSibling;return o.remove(),()=>{r.value&&r.value.insertBefore(o,C)}}const d=X.get(o);if(!d)return;const w=o.style.width;return o.style.width=d,()=>{o.style.width=w}}),v=z(r.value);i.value=v;for(let o=f.length-1;o>=0;o--){const d=f[o];d&&d()}},{immediate:!0,flush:"post"});const p=e.toRef(t,"justify");U({justify:p});let m=t.parts;e.watch(()=>t.parts,f=>{const v=new Map(f.map(d=>[d.key,{...d,isPresent:!0}]));m=[...m.filter(d=>!v.get(d.key)).map(d=>({...d,isPresent:!1})),...f].sort((d,w)=>p.value==="right"?d.isPresent===w.isPresent?d.originalIndex-w.originalIndex:d.isPresent?-1:1:p.value==="left"?d.isPresent===w.isPresent?d.originalIndex-w.originalIndex:d.isPresent?1:-1:d.originalIndex-w.originalIndex)});function x(f){m=m.filter(v=>v.key!==f)}return(f,v)=>(e.openBlock(),e.createBlock(e.unref(u.motion).span,{ref:l,class:e.normalizeClass(`number-section-${f.name}`),style:e.normalizeStyle({...f.style,display:"inline-flex",justifyContent:p.value,width:i.value}),layout:"position"},{default:e.withCtx(()=>[e.createElementVNode("span",{ref_key:"measuredRef",ref:r,style:{display:"inline-flex",justifyContent:"inherit",position:"relative"}},[v[0]||(v[0]=e.createTextVNode(" ")),e.createVNode(e.unref(u.AnimatePresence),{multiple:"",mode:f.mode,"anchor-x":p.value,initial:!1},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(m),o=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:o.key},[o.type==="integer"||o.type==="fraction"?(e.openBlock(),e.createBlock(Q,{key:o.key,"part-key":o.key,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},value:o.value,"is-present":o.isPresent??!0,"initial-value":e.unref(h).current?void 0:0,onRemove:x},null,8,["part-key","value","is-present","initial-value"])):(e.openBlock(),e.createBlock(J,{key:o.type==="literal"?`${o.key}:${o.value}`:o.key,type:o.type,"part-key":o.key,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},value:o.value,"is-present":o.isPresent??!0,onRemove:x},null,8,["type","part-key","value","is-present"]))],64))),128))]),_:1},8,["mode","anchor-x"])],512)]),_:1},8,["class","style"]))}}),ee=e.defineComponent({__name:"Mask",setup(n){return(t,i)=>(e.openBlock(),e.createBlock(e.unref(u.motion).span,{layout:"","aria-hidden":!0,style:e.normalizeStyle({display:"inline-flex","--invert-x":1,margin:`0 calc(-1*${e.unref(_)})`,padding:`calc(${e.unref(k)}/2) ${e.unref(_)}`,position:"relative",zIndex:-1,overflow:"clip",webkitMaskImage:e.unref(q),webkitMaskSize:e.unref(Z),webkitMaskPosition:"center, center, top left, top right, bottom right, bottom left",webkitMaskRepeat:"no-repeat"})},{default:e.withCtx(()=>[e.renderSlot(t.$slots,"default")]),_:3},8,["style"]))}}),te=e.defineComponent({name:"AnimateNumber",__name:"AnimateNumber",props:{locales:{},format:{},transition:{},suffix:{},prefix:{},value:{},style:{}},setup(n){const t={opacity:{duration:1,ease:u.easeOut},layout:{type:"spring",duration:1,bounce:0},y:{type:"spring",duration:1,bounce:0}},i=n,a=e.computed(()=>{const p=i.value;return K(p,{locales:i.locales,format:i.format},i.prefix,i.suffix)}),l=u.useMotionConfig(),r=e.computed(()=>i.transition??l.value.transition??t);function h(){const{format:p,prefix:m,suffix:x,locales:f,value:v,...o}=i;return o}return(p,m)=>(e.openBlock(),e.createBlock(e.unref(u.LayoutGroup),null,{default:e.withCtx(()=>[e.createVNode(e.unref(u.MotionConfig),{transition:r.value},{default:e.withCtx(()=>[e.createVNode(e.unref(u.motion).div,e.mergeProps({...p.$attrs,...h()},{layout:"",style:{lineHeight:"1",...p.style,display:"inline-flex",isolation:"isolate",whiteSpace:"nowrap"}}),{default:e.withCtx(()=>[e.createVNode(e.unref(u.motion).div,{layout:"","aria-label":a.value.formatted,style:{display:"inline-flex",direction:"ltr",isolation:"isolate",position:"relative",zIndex:-1}},{default:e.withCtx(()=>[e.createVNode($,{style:e.normalizeStyle({padding:`calc(${e.unref(k)}/2) 0`}),"aria-hidden":!0,justify:"right",mode:"popLayout",parts:a.value.pre,name:"pre"},null,8,["style","parts"]),e.createVNode(ee,null,{default:e.withCtx(()=>[e.createVNode($,{justify:"right",parts:a.value.integer,name:"integer",mode:"popLayout"},null,8,["parts"]),e.createVNode($,{layout:"position",parts:a.value.fraction,name:"fraction",mode:"popLayout"},null,8,["parts"])]),_:1}),e.createVNode($,{style:e.normalizeStyle({padding:`calc(${e.unref(k)}/2) 0`}),"aria-hidden":!0,layout:"position",mode:"popLayout",parts:a.value.post,name:"post"},null,8,["style","parts"])]),_:1},8,["aria-label"])]),_:1},16,["style"])]),_:1},8,["transition"])]),_:1}))}}),ne=te;function oe(){const n=document.createElement("style");return n.textContent=`
|
|
2
2
|
* {
|
|
3
3
|
cursor: none !important;
|
|
4
4
|
}
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
[data-motion-cursor="pointer"] {
|
|
7
7
|
background-color: #333;
|
|
8
8
|
}
|
|
9
|
-
`,document.head.appendChild(n),()=>{document.head.removeChild(n)}}function ie(n){e.watch(n,
|
|
9
|
+
`,document.head.appendChild(n),()=>{document.head.removeChild(n)}}function ie(n){e.watch(n,t=>t?oe():u.noop)}function L(n){return t=>{t.pointerType==="mouse"&&n(t)}}function R(n){return L(t=>{t.button===0&&n(t)})}let T,V;function re(){T=u.motionValue(0),V=u.motionValue(0);let n=0,t=0;function i(){T.set(n),V.set(t)}typeof window<"u"&&window.addEventListener("pointermove",L(a=>{n=a.clientX,t=a.clientY,u.frame.update(i)}))}function ae(){return T||re(),{x:T,y:V}}function se(n,t){return{x:u.useTransform(()=>n.x.get()+t.value.x),y:u.useTransform(()=>n.y.get()+t.value.y)}}function ue(n){return n.closest("[data-cursor]")}function le(n){return n.closest('a, button, input[type="button"]:not(:disabled)')}function ce(n){return window.getComputedStyle(n).userSelect==="none"?null:n.closest("p, textarea:not(:disabled), input[type='text']:not(:disabled), h1, h2, h3, h4, h5, h6")}function fe(n){let t=ue(n);return t?[t.dataset.cursor,t]:(t=le(n),t?["pointer",t]:(t=ce(n),t?["text",t]:["default",null]))}let E=null,S={type:"default",isPressed:!1,fontSize:null,targetBoundingBox:null};function de(){if(typeof window>"u")return{onChange:()=>()=>{}};const n=new Set;function t(p){S={...S,...p},n.forEach(m=>m(S))}const i=R(()=>{S.isPressed||t({isPressed:!0})}),a=R(()=>{S.isPressed&&t({isPressed:!1})}),l=L(({target:p})=>{if(!p)return;const[m,x]=fe(p);let f=!1;const v={};m!==S.type&&(v.type=m,f=!0);const o=m==="pointer"&&x?x.getBoundingClientRect():null;if(o!==S.targetBoundingBox&&(v.targetBoundingBox=o,f=!0),m==="text"){const{fontSize:d}=window.getComputedStyle(p),w=d?parseInt(d):null;w!==S.fontSize&&(v.fontSize=w,f=!0)}else S.fontSize&&(v.fontSize=null,f=!0);f&&t(v)});function r(){typeof window>"u"||(window.addEventListener("pointerover",l),window.addEventListener("pointerdown",i),window.addEventListener("pointerup",a))}function h(){window.removeEventListener("pointerover",l),window.removeEventListener("pointerdown",i),window.removeEventListener("pointerup",a)}return{onChange:p=>(n.size||r(),n.add(p),()=>{n.delete(p),n.size||h()})}}function pe(){return E||(E=de()),E}function me(){const n=e.ref({...S});return e.watch(n,()=>pe().onChange(t=>{n.value=t}),{immediate:!0,flush:"post"}),n}let I=null;function ye(){const n=new Set;function t(){n.forEach(r=>r.show())}function i(){n.forEach(r=>r.hide())}function a(){document.body.addEventListener("mouseenter",t),document.body.addEventListener("mouseleave",i)}function l(){document.body.removeEventListener("mouseenter",t),document.body.removeEventListener("mouseleave",i)}return{on:r=>typeof window>"u"?u.noop:(n.size||a(),n.add(r),()=>{n.delete(r),n.size===0&&l()})}}function ve(){return I||(I=ye()),I}function ge(n){const t=e.ref(!0);return e.watch(t,()=>ve().on({show:()=>{t.value||(n(),t.value=!0)},hide:()=>t.value=!1}),{immediate:!0}),t}function j(n,t,i){return u.useTransform(()=>u.mix(n.get(),t.get(),i.get()))}function he(n,t,i){const a=u.useMotionValue(0),l=u.useMotionValue(0),r=u.useMotionValue(0),h=j(n.x,l,a),p=j(n.y,r,a);return e.watch([t,()=>i.value.targetBoundingBox],()=>{if(!t.value)return;i.value.targetBoundingBox&&(l.set(i.value.targetBoundingBox.left+i.value.targetBoundingBox.width/2),r.set(i.value.targetBoundingBox.top+i.value.targetBoundingBox.height/2));const m=u.animate(a,i.value.targetBoundingBox?.9:0);return()=>m.stop()},{immediate:!0}),{x:h,y:p}}const we={width:"auto",height:"auto"},A={x:0,y:0},xe={x:.5,y:.5},ke={stiffness:1e3,damping:100},Ce={duration:.15,ease:[.38,.12,.29,1]},F=16,D=30,H=4,Be=20;function Se(n,t,{matchPointerSize:i,matchTextSize:a}){switch(n){case"pointer":return i&&t.targetBoundingBox?t.targetBoundingBox:{width:D,height:D};case"text":return a&&t.fontSize?{width:H,height:t.fontSize}:{width:H,height:Be};default:return{width:F,height:F}}}function Pe({x:n,y:t},i){const a=e.ref(n.prev!==void 0||t.prev!==void 0);return e.watch(a,()=>{if(a.value)return;const l=()=>{a.value=!0,i(),r()},r=u.pipe(n.on("change",l),t.on("change",l));return()=>r()},{immediate:!0}),a}const be=e.defineComponent({__name:"Cursor",props:{follow:{type:Boolean,default:!1},center:{default:({follow:n})=>n?A:xe},offset:{default:()=>A},spring:{type:[Boolean,Object],default:({follow:n})=>n?ke:!1},snapToTarget:{type:Boolean,default:!1},matchTextSize:{type:Boolean,default:!0},transition:{},variants:{},style:{}},setup(n){const t=n,i=e.toRef(t,"offset");ie(()=>t.follow);const a=ae(),l=se(a,i),r=u.useSpring(l.x,t.spring||void 0),h=u.useSpring(l.y,t.spring||void 0);function p(){const c=l.x.on("change",g=>{r.jump(g),c()}),s=l.y.on("change",g=>{h.jump(g),s()})}const m=me(),x=ge(p),{x:f,y:v}=he(t.spring?{x:r,y:h}:a,e.toRef(t,"snapToTarget"),m),o=e.useSlots(),d=e.computed(()=>{var g,B;const c=(B=(g=o.default)==null?void 0:g.call(o))==null?void 0:B.filter(N=>N.type!==Symbol.for("v-cmt"));if(c!=null&&c.length)return we;const s=Se(m.value.type,m.value,{matchPointerSize:t.snapToTarget,matchTextSize:t.matchTextSize});return{width:`${s.width}px`,height:`${s.height}px`}}),w=Pe(a,p);function C(c){return(s,g)=>`translate(-${c.x*100}%, -${c.y*100}%) ${g}`}function y(){const{follow:c,center:s,offset:g,spring:B,snapToTarget:N,matchTextSize:Te,...Y}=t;return{...Y}}return(c,s)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.unref(w)?(e.openBlock(),e.createBlock(e.unref(u.LayoutGroup),{key:0},{default:e.withCtx(()=>[e.createVNode(e.unref(u.MotionConfig),{transition:t.transition||e.unref(Ce)},{default:e.withCtx(()=>[e.createVNode(e.unref(u.motion).div,e.mergeProps({layout:"","data-motion-cursor":c.follow?"follow":"pointer","data-framer-portal-id":"motion-cursor",initial:"exit",exit:"exit"},{...c.$attrs,...y()},{variants:{default:{opacity:1,scale:1},exit:{opacity:0,scale:0},pressed:c.follow?{opacity:1,scale:1}:{opacity:1,scale:.9},...c.variants},animate:["default",e.unref(m).type,e.unref(x)?e.unref(m).isPressed?"pressed":"":"exit"],"transform-template":C(c.center),"data-w":d.value.width,style:{width:d.value.width,height:d.value.height,borderRadius:c.follow?0:20,zIndex:c.follow?99998:99999,willChange:"transform",contain:"layout",overflow:"hidden",originX:c.center.x,originY:c.center.y,...t.style,x:e.unref(f),y:e.unref(v),top:0,left:0,position:"fixed",pointerEvents:"none"}}),{default:e.withCtx(()=>[e.createVNode(e.unref(u.AnimatePresence),{multiple:""},{default:e.withCtx(()=>[e.renderSlot(c.$slots,"default")]),_:3})]),_:3},16,["data-motion-cursor","variants","animate","transform-template","data-w","style"])]),_:3},8,["transition"])]),_:3})):e.createCommentVNode("",!0)]))}}),$e=be;exports.AnimateNumber=ne;exports.Cursor=$e;
|
|
@@ -13,7 +13,7 @@ export interface CursorProps {
|
|
|
13
13
|
}
|
|
14
14
|
declare const state: import('vue').Ref<import('./hooks/use-cursor-state/types').CursorState, import('./hooks/use-cursor-state/types').CursorState>;
|
|
15
15
|
declare const isInView: import('vue').Ref<boolean, boolean>;
|
|
16
|
-
declare const x: import('motion-v').MotionValue<number>, y: import('motion-v').MotionValue<number>;
|
|
16
|
+
declare const x: import('motion-v/es').MotionValue<number>, y: import('motion-v/es').MotionValue<number>;
|
|
17
17
|
declare const size: import('vue').ComputedRef<{
|
|
18
18
|
width: string;
|
|
19
19
|
height: string;
|
|
@@ -46,19 +46,19 @@ declare const __VLS_self: import('vue').DefineComponent<CursorProps, {
|
|
|
46
46
|
reset: typeof reset;
|
|
47
47
|
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<CursorProps> & Readonly<{}>, {
|
|
48
48
|
offset: Point;
|
|
49
|
-
follow: boolean;
|
|
50
49
|
center: Point;
|
|
51
50
|
spring: false | SpringOptions;
|
|
52
|
-
snapToTarget: boolean;
|
|
53
51
|
matchTextSize: boolean;
|
|
52
|
+
follow: boolean;
|
|
53
|
+
snapToTarget: boolean;
|
|
54
54
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
55
55
|
declare const __VLS_component: import('vue').DefineComponent<CursorProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<CursorProps> & Readonly<{}>, {
|
|
56
56
|
offset: Point;
|
|
57
|
-
follow: boolean;
|
|
58
57
|
center: Point;
|
|
59
58
|
spring: false | SpringOptions;
|
|
60
|
-
snapToTarget: boolean;
|
|
61
59
|
matchTextSize: boolean;
|
|
60
|
+
follow: boolean;
|
|
61
|
+
snapToTarget: boolean;
|
|
62
62
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
63
63
|
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
64
64
|
export default _default;
|
|
@@ -2,6 +2,6 @@ import { MotionPoint } from './use-offset';
|
|
|
2
2
|
import { CursorState } from './use-cursor-state/types';
|
|
3
3
|
import { Ref } from 'vue';
|
|
4
4
|
export declare function useSnapToTarget(pointer: MotionPoint, isEnabled: Ref<boolean>, state: Ref<CursorState>): {
|
|
5
|
-
x: import('motion-v').MotionValue<number>;
|
|
6
|
-
y: import('motion-v').MotionValue<number>;
|
|
5
|
+
x: import('motion-v/es').MotionValue<number>;
|
|
6
|
+
y: import('motion-v/es').MotionValue<number>;
|
|
7
7
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { defineComponent as M, ref as u, watch as y, nextTick as W, createBlock as s, openBlock as o, unref as
|
|
1
|
+
import { defineComponent as M, ref as u, watch as y, nextTick as W, createBlock as s, openBlock as o, unref as a, normalizeStyle as v, withCtx as j, createElementVNode as A, createElementBlock as m, createCommentVNode as R, Fragment as V, renderList as b, resolveDynamicComponent as g, createVNode as F } from "vue";
|
|
2
2
|
import { useMotionConfig as K, motion as S, animate as T } from "motion-v";
|
|
3
3
|
import { useIsInitialRender as z } from "./hooks/use-is-initial-render.mjs";
|
|
4
|
-
import { digitFillStyle as
|
|
4
|
+
import { digitFillStyle as x, maskHeight as H } from "./config.mjs";
|
|
5
5
|
import { useAnimate as L } from "./use-animate.mjs";
|
|
6
6
|
import { getWidthInEm as Y } from "./utils/get-width-in-ems.mjs";
|
|
7
7
|
import { targetWidths as $ } from "./utils/target-widths.mjs";
|
|
@@ -20,14 +20,14 @@ const Z = /* @__PURE__ */ M({
|
|
|
20
20
|
style: {}
|
|
21
21
|
},
|
|
22
22
|
setup(w) {
|
|
23
|
-
const
|
|
23
|
+
const r = w, c = r.initialValue ?? r.value, h = z(), I = K(), l = u(), k = u(Array(10).fill(null)), C = u(), {
|
|
24
24
|
getRoot: N,
|
|
25
|
-
handleComplete:
|
|
25
|
+
handleComplete: P,
|
|
26
26
|
root: p
|
|
27
|
-
} = L(
|
|
27
|
+
} = L(r);
|
|
28
28
|
let d = c;
|
|
29
29
|
const t = u(c);
|
|
30
|
-
y([() =>
|
|
30
|
+
y([() => r.value, () => r.isPresent], ([e, n]) => {
|
|
31
31
|
if (!n)
|
|
32
32
|
return t.value = 0;
|
|
33
33
|
if (h.current)
|
|
@@ -39,20 +39,20 @@ const Z = /* @__PURE__ */ M({
|
|
|
39
39
|
immediate: !0
|
|
40
40
|
});
|
|
41
41
|
function D(e) {
|
|
42
|
-
var
|
|
42
|
+
var B;
|
|
43
43
|
if (!l.value || e === d) return;
|
|
44
|
-
const n = l.value.getBoundingClientRect(), i = (
|
|
44
|
+
const n = l.value.getBoundingClientRect(), i = (B = p.value) == null ? void 0 : B.getBoundingClientRect(), _ = n.height * (e - d) + (n.top - (i ? i.top || 0 : n.top));
|
|
45
45
|
T(l.value, {
|
|
46
|
-
y: [
|
|
46
|
+
y: [_, 0]
|
|
47
47
|
}, I.value.transition);
|
|
48
48
|
}
|
|
49
|
-
function
|
|
49
|
+
function E(e) {
|
|
50
50
|
if (h.current && c === e || !k.value[e]) return;
|
|
51
51
|
const n = Y(k.value[e]);
|
|
52
52
|
p.value && $.set(p.value, n), C.value = n;
|
|
53
53
|
}
|
|
54
54
|
y(t, (e) => {
|
|
55
|
-
|
|
55
|
+
E(e);
|
|
56
56
|
}, {
|
|
57
57
|
immediate: !0,
|
|
58
58
|
flush: "post"
|
|
@@ -73,18 +73,19 @@ const Z = /* @__PURE__ */ M({
|
|
|
73
73
|
}
|
|
74
74
|
}, [e]);
|
|
75
75
|
}
|
|
76
|
-
return (e, n) => (o(), s(
|
|
77
|
-
ref:
|
|
76
|
+
return (e, n) => (o(), s(a(S).span, {
|
|
77
|
+
ref: a(N),
|
|
78
78
|
layout: "position",
|
|
79
79
|
"data-state": e.isPresent ? void 0 : "exiting",
|
|
80
80
|
"data-key": e.partKey,
|
|
81
81
|
style: v({
|
|
82
82
|
display: "inline-flex",
|
|
83
83
|
justifyContent: "center",
|
|
84
|
-
width: C.value
|
|
84
|
+
width: C.value,
|
|
85
|
+
pointerEvents: e.isPresent ? void 0 : "none"
|
|
85
86
|
}),
|
|
86
87
|
"aria-hidden": !e.isPresent,
|
|
87
|
-
onMotioncomplete:
|
|
88
|
+
onMotioncomplete: a(P)
|
|
88
89
|
}, {
|
|
89
90
|
default: j(() => [A("span", {
|
|
90
91
|
ref_key: "scope",
|
|
@@ -99,22 +100,22 @@ const Z = /* @__PURE__ */ M({
|
|
|
99
100
|
}, [t.value !== 0 ? (o(), m("span", {
|
|
100
101
|
key: 0,
|
|
101
102
|
style: v({
|
|
102
|
-
...
|
|
103
|
+
...a(x),
|
|
103
104
|
bottom: "100%",
|
|
104
105
|
left: 0
|
|
105
106
|
})
|
|
106
|
-
}, [(o(!0), m(
|
|
107
|
+
}, [(o(!0), m(V, null, b(t.value, (i) => (o(), s(g(f(i - 1)), {
|
|
107
108
|
key: i - 1
|
|
108
|
-
}))), 128))], 4)) :
|
|
109
|
+
}))), 128))], 4)) : R("", !0), (o(), s(g(f(t.value)))), t.value !== 9 ? (o(), m("span", {
|
|
109
110
|
key: 1,
|
|
110
111
|
style: v({
|
|
111
|
-
...
|
|
112
|
+
...a(x),
|
|
112
113
|
top: "100%",
|
|
113
114
|
left: 0
|
|
114
115
|
})
|
|
115
|
-
}, [(o(!0), m(
|
|
116
|
+
}, [(o(!0), m(V, null, b(9 - t.value, (i) => (o(), s(g(f(t.value + i)), {
|
|
116
117
|
key: t.value + i
|
|
117
|
-
}))), 128))], 4)) :
|
|
118
|
+
}))), 128))], 4)) : R("", !0)], 512)]),
|
|
118
119
|
_: 1
|
|
119
120
|
}, 8, ["data-state", "data-key", "style", "aria-hidden", "onMotioncomplete"]));
|
|
120
121
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { defineComponent as u, createBlock as n, openBlock as a, unref as e, normalizeStyle as
|
|
1
|
+
import { defineComponent as u, createBlock as n, openBlock as a, unref as e, normalizeStyle as d, withCtx as i, createVNode as y, createTextVNode as c, toDisplayString as f } from "vue";
|
|
2
2
|
import { motion as l, AnimatePresence as h } from "motion-v";
|
|
3
|
-
import { maskHeight as
|
|
4
|
-
import { useSectionContext as
|
|
5
|
-
import { useAnimate as
|
|
3
|
+
import { maskHeight as v } from "./config.mjs";
|
|
4
|
+
import { useSectionContext as g } from "./context.mjs";
|
|
5
|
+
import { useAnimate as k } from "./use-animate.mjs";
|
|
6
6
|
const B = /* @__PURE__ */ u({
|
|
7
7
|
__name: "NumberSymbol",
|
|
8
8
|
props: {
|
|
@@ -14,16 +14,17 @@ const B = /* @__PURE__ */ u({
|
|
|
14
14
|
style: {}
|
|
15
15
|
},
|
|
16
16
|
setup(r) {
|
|
17
|
-
const s = r, { justify: o } =
|
|
18
|
-
return (t,
|
|
17
|
+
const s = r, { justify: o } = g(), { getRoot: p, handleComplete: m } = k(s);
|
|
18
|
+
return (t, x) => (a(), n(e(l).span, {
|
|
19
19
|
ref: e(p),
|
|
20
20
|
layout: "position",
|
|
21
21
|
"data-state": t.isPresent ? void 0 : "exiting",
|
|
22
|
-
style:
|
|
22
|
+
style: d({
|
|
23
23
|
display: "inline-flex",
|
|
24
24
|
justifyContent: e(o),
|
|
25
|
-
padding: `calc(${e(
|
|
26
|
-
position: "relative"
|
|
25
|
+
padding: `calc(${e(v)}/2) 0`,
|
|
26
|
+
position: "relative",
|
|
27
|
+
pointerEvents: t.isPresent ? void 0 : "none"
|
|
27
28
|
}),
|
|
28
29
|
"aria-hidden": !t.isPresent,
|
|
29
30
|
onMotioncomplete: e(m)
|
|
@@ -56,7 +57,7 @@ const B = /* @__PURE__ */ u({
|
|
|
56
57
|
}
|
|
57
58
|
}, {
|
|
58
59
|
default: i(() => [
|
|
59
|
-
|
|
60
|
+
c(f(t.value), 1)
|
|
60
61
|
]),
|
|
61
62
|
_: 1
|
|
62
63
|
}, 8, ["layout"]))
|
|
@@ -1,40 +1,37 @@
|
|
|
1
|
-
import { noop as
|
|
1
|
+
import { noop as s } from "motion-v";
|
|
2
2
|
import { ref as d, watch as f } from "vue";
|
|
3
|
-
let
|
|
3
|
+
let r = null;
|
|
4
4
|
function m() {
|
|
5
5
|
const e = /* @__PURE__ */ new Set();
|
|
6
6
|
function n() {
|
|
7
7
|
e.forEach((t) => t.show());
|
|
8
8
|
}
|
|
9
|
-
function
|
|
9
|
+
function o() {
|
|
10
10
|
e.forEach((t) => t.hide());
|
|
11
11
|
}
|
|
12
|
-
function
|
|
13
|
-
document.body.addEventListener("mouseenter", n), document.body.addEventListener("mouseleave",
|
|
12
|
+
function i() {
|
|
13
|
+
document.body.addEventListener("mouseenter", n), document.body.addEventListener("mouseleave", o);
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
document.body.removeEventListener("mouseenter", n), document.body.removeEventListener("mouseleave",
|
|
15
|
+
function u() {
|
|
16
|
+
document.body.removeEventListener("mouseenter", n), document.body.removeEventListener("mouseleave", o);
|
|
17
17
|
}
|
|
18
18
|
return {
|
|
19
|
-
on: (t) => typeof window > "u" ?
|
|
20
|
-
e.delete(t), e.size === 0 &&
|
|
19
|
+
on: (t) => typeof window > "u" ? s : (e.size || i(), e.add(t), () => {
|
|
20
|
+
e.delete(t), e.size === 0 && u();
|
|
21
21
|
})
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
function c() {
|
|
25
|
-
return
|
|
25
|
+
return r || (r = m()), r;
|
|
26
26
|
}
|
|
27
27
|
function l(e) {
|
|
28
28
|
const n = d(!0);
|
|
29
|
-
return f(n, (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
});
|
|
36
|
-
o(t);
|
|
37
|
-
}, { immediate: !0 }), n;
|
|
29
|
+
return f(n, () => c().on({
|
|
30
|
+
show: () => {
|
|
31
|
+
n.value || (e(), n.value = !0);
|
|
32
|
+
},
|
|
33
|
+
hide: () => n.value = !1
|
|
34
|
+
}), { immediate: !0 }), n;
|
|
38
35
|
}
|
|
39
36
|
export {
|
|
40
37
|
l as useCursorIsInView
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { onlyMouse as g, onlyLeftClicks as
|
|
1
|
+
import { onlyMouse as g, onlyLeftClicks as v } from "../utils/only-mouse-events.mjs";
|
|
2
2
|
import { findTarget as z } from "./find-target.mjs";
|
|
3
3
|
import { ref as L, watch as h } from "vue";
|
|
4
|
-
let
|
|
4
|
+
let d = null, e = {
|
|
5
5
|
type: "default",
|
|
6
6
|
isPressed: !1,
|
|
7
7
|
fontSize: null,
|
|
@@ -14,53 +14,50 @@ function P() {
|
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
16
|
const t = /* @__PURE__ */ new Set();
|
|
17
|
-
function
|
|
18
|
-
e = { ...e, ...n }, t.forEach((
|
|
17
|
+
function o(n) {
|
|
18
|
+
e = { ...e, ...n }, t.forEach((i) => i(e));
|
|
19
19
|
}
|
|
20
|
-
const
|
|
21
|
-
e.isPressed ||
|
|
22
|
-
}),
|
|
23
|
-
e.isPressed &&
|
|
24
|
-
}),
|
|
20
|
+
const u = v(() => {
|
|
21
|
+
e.isPressed || o({ isPressed: !0 });
|
|
22
|
+
}), f = v(() => {
|
|
23
|
+
e.isPressed && o({ isPressed: !1 });
|
|
24
|
+
}), l = g(({ target: n }) => {
|
|
25
25
|
if (!n)
|
|
26
26
|
return;
|
|
27
|
-
const [
|
|
28
|
-
let
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
if (
|
|
33
|
-
const { fontSize:
|
|
27
|
+
const [i, a] = z(n);
|
|
28
|
+
let r = !1;
|
|
29
|
+
const s = {};
|
|
30
|
+
i !== e.type && (s.type = i, r = !0);
|
|
31
|
+
const p = i === "pointer" && a ? a.getBoundingClientRect() : null;
|
|
32
|
+
if (p !== e.targetBoundingBox && (s.targetBoundingBox = p, r = !0), i === "text") {
|
|
33
|
+
const { fontSize: w } = window.getComputedStyle(
|
|
34
34
|
n
|
|
35
|
-
),
|
|
36
|
-
|
|
35
|
+
), c = w ? parseInt(w) : null;
|
|
36
|
+
c !== e.fontSize && (s.fontSize = c, r = !0);
|
|
37
37
|
} else
|
|
38
|
-
e.fontSize && (
|
|
39
|
-
|
|
38
|
+
e.fontSize && (s.fontSize = null, r = !0);
|
|
39
|
+
r && o(s);
|
|
40
40
|
});
|
|
41
|
-
function
|
|
42
|
-
typeof window > "u" || (window.addEventListener("pointerover",
|
|
41
|
+
function m() {
|
|
42
|
+
typeof window > "u" || (window.addEventListener("pointerover", l), window.addEventListener("pointerdown", u), window.addEventListener("pointerup", f));
|
|
43
43
|
}
|
|
44
44
|
function S() {
|
|
45
|
-
window.removeEventListener("pointerover",
|
|
45
|
+
window.removeEventListener("pointerover", l), window.removeEventListener("pointerdown", u), window.removeEventListener("pointerup", f);
|
|
46
46
|
}
|
|
47
47
|
return {
|
|
48
|
-
onChange: (n) => (t.size ||
|
|
48
|
+
onChange: (n) => (t.size || m(), t.add(n), () => {
|
|
49
49
|
t.delete(n), t.size || S();
|
|
50
50
|
})
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
function y() {
|
|
54
|
-
return
|
|
54
|
+
return d || (d = P()), d;
|
|
55
55
|
}
|
|
56
56
|
function x() {
|
|
57
57
|
const t = L({ ...e });
|
|
58
|
-
return h(t, (
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
});
|
|
62
|
-
d(u);
|
|
63
|
-
}, { immediate: !0, flush: "post" }), t;
|
|
58
|
+
return h(t, () => y().onChange((o) => {
|
|
59
|
+
t.value = o;
|
|
60
|
+
}), { immediate: !0, flush: "post" }), t;
|
|
64
61
|
}
|
|
65
62
|
export {
|
|
66
63
|
x as useCursorState
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { noop as
|
|
2
|
-
import { watch as
|
|
3
|
-
function
|
|
4
|
-
const
|
|
5
|
-
return
|
|
1
|
+
import { noop as e } from "motion-v";
|
|
2
|
+
import { watch as n } from "vue";
|
|
3
|
+
function r() {
|
|
4
|
+
const t = document.createElement("style");
|
|
5
|
+
return t.textContent = `
|
|
6
6
|
* {
|
|
7
7
|
cursor: none !important;
|
|
8
8
|
}
|
|
@@ -10,18 +10,13 @@ function m() {
|
|
|
10
10
|
[data-motion-cursor="pointer"] {
|
|
11
11
|
background-color: #333;
|
|
12
12
|
}
|
|
13
|
-
`, document.head.appendChild(
|
|
14
|
-
document.head.removeChild(
|
|
13
|
+
`, document.head.appendChild(t), () => {
|
|
14
|
+
document.head.removeChild(t);
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
const n = t ? m() : r;
|
|
20
|
-
e(() => {
|
|
21
|
-
n(0);
|
|
22
|
-
});
|
|
23
|
-
});
|
|
17
|
+
function u(t) {
|
|
18
|
+
n(t, (o) => o ? r() : e);
|
|
24
19
|
}
|
|
25
20
|
export {
|
|
26
|
-
|
|
21
|
+
u as useCursorStyles
|
|
27
22
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "motion-plus-vue",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Motion Plus Vue",
|
|
5
5
|
"author": "",
|
|
6
6
|
"license": "ISC",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"size-limit": [
|
|
36
36
|
{
|
|
37
37
|
"path": "dist/es/components/AnimateNumber/index.mjs",
|
|
38
|
-
"limit": "3.
|
|
38
|
+
"limit": "3.6 kb",
|
|
39
39
|
"ignore": [
|
|
40
40
|
"vue",
|
|
41
41
|
"motion-v"
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
},
|
|
44
44
|
{
|
|
45
45
|
"path": "dist/es/components/Cursor/index.mjs",
|
|
46
|
-
"limit": "2.
|
|
46
|
+
"limit": "2.7 kb",
|
|
47
47
|
"ignore": [
|
|
48
48
|
"vue",
|
|
49
49
|
"motion-v"
|