framer-motion-theatre
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -1,2 +0,2 @@ | ||
import{createContext as x,useContext as S,useEffect as c,useMemo as R,useState as d}from"react";import{motionValue as M}from"framer-motion";import{createRoot as G}from"react-dom/client";import{jsx as f}from"react/jsx-runtime";var y=x(null),N=({project:r,studio:i,children:u,theme:n})=>{let m={normalColor:"rgb(173, 173, 173)",selectedColor:"rgb(79, 167, 255)",width:3};return f(y.Provider,{value:{project:r,studio:i,gizmoTheme:n??m},children:u})},E=x(null);function $(r,i){return u=>{let{project:n}=S(y),[m]=d(()=>n.sheet(r,u.animationId));return f(E.Provider,{value:{sheet:m},children:f(i,{...u})})}}var z=()=>{};function I(r,i){return()=>{i.setSelection([r])}}function q(r,i){let{sheet:u}=S(E),{studio:n,gizmoTheme:m}=S(y),[g,C]=d(!1),[b,P]=d(!1),[t,L]=d(null),[a,T]=d(),[h,j]=d(!1),[l,V]=d(()=>u.object(r,i,{reconfigure:!0})),[p,w]=d(()=>{let e={};for(let o in l.value)e[o]=M(l.value[o]);return e}),[v,k]=d(()=>n?I(l,n):z);c(()=>{n?(k(()=>I(l,n)),P(n.selection.includes(l)),n.onSelectionChange(e=>{P(e.includes(l))})):(k(z),P(!1))},[l,n]);let O=R(()=>({...p,$studio:{isSelected:b,select:v,setSelectionTarget:L}}),[p,v,b]);return c(()=>{w(e=>{let o={};for(let s in l.value)e[s]?o[s]=e[s]:o[s]=M(l.value[s]);return o})},[l]),c(()=>l.onValuesChange(o=>{for(let s in o)p[s]&&p[s].set(o[s])}),[l,p]),c(()=>{V(u.object(r,i,{reconfigure:!0}))},[i,r,u]),c(()=>{if(!t)return;let e=document.createElement("div"),o=G(e);return T({root:o,domElement:e}),()=>{o.unmount(),e.remove(),T(null)}},[t]),c(()=>{!a||!t||(h&&t.appendChild(a.domElement),a.root.render(f(H,{selectionTarget:t,selectFn:v,isSelected:b,isHovered:g,theme:m})))},[a,m,h,g,b,v,t]),c(()=>{let e=s=>{s.altKey===!0&&j(!0)},o=s=>{s.altKey===!1&&j(!1)};return document.addEventListener("keydown",e),document.addEventListener("keyup",o),()=>{document.removeEventListener("keydown",e),document.removeEventListener("keyup",o)}},[]),c(()=>{if(!h||!a||!t)return;t.appendChild(a.domElement);let e=t.style.position;return t.style.position="relative",()=>{try{t.removeChild(a.domElement)}catch{}t.style.position=e}},[h,a,t]),c(()=>{if(!t)return;let e=()=>C(!0),o=()=>C(!1);return t.addEventListener("mouseenter",e),t.addEventListener("mouseleave",o),()=>{C(!1),t.removeEventListener("mouseenter",e),t.removeEventListener("mouseleave",o)}},[t]),c(()=>{if(!t)return;let e=o=>{h&&(o.stopPropagation(),v())};return t.addEventListener("click",e),()=>{t.removeEventListener("click",e)}}),O}function B(){let{sheet:r}=S(E);return r.sequence}function H({selectFn:r,isSelected:i,isHovered:u,theme:n}){return f("div",{style:{position:"absolute",inset:0,pointerEvents:"none",borderWidth:n.width,borderStyle:i?"solid":"dashed",borderColor:i||u?n.selectedColor:n.normalColor,boxSizing:"border-box",zIndex:1e3},onClick:r})}export{N as TheatreProvider,B as useControls,q as useSheetObject,$ as withTheatre}; | ||
import{createContext as x,useContext as S,useEffect as c,useMemo as R,useState as d}from"react";import{motionValue as M}from"framer-motion";import{createRoot as G}from"react-dom/client";import{jsx as f}from"react/jsx-runtime";var y=x(null),D=({project:r,studio:i,children:u,theme:n})=>{let m={normalColor:"rgb(173, 173, 173)",selectedColor:"rgb(79, 167, 255)",width:3};return f(y.Provider,{value:{project:r,studio:i,gizmoTheme:n??m},children:u})},E=x(null);function N(r,i){return u=>{let{project:n}=S(y),[m]=d(()=>n.sheet(r,u.animationId));return f(E.Provider,{value:{sheet:m},children:f(i,{...u})})}}var z=()=>{};function I(r,i){return()=>{i.setSelection([r])}}function q(r,i){let{sheet:u}=S(E),{studio:n,gizmoTheme:m}=S(y),[g,C]=d(!1),[b,P]=d(!1),[t,L]=d(null),[a,T]=d(),[h,j]=d(!1),[l,V]=d(()=>u.object(r,i,{reconfigure:!0})),[p,w]=d(()=>{let e={};for(let o in l.value)e[o]=M(l.value[o]);return e}),[v,k]=d(()=>n?I(l,n):z);c(()=>{n?(k(()=>I(l,n)),P(n.selection.includes(l)),n.onSelectionChange(e=>{P(e.includes(l))})):(k(z),P(!1))},[l,n]);let O=R(()=>({...p,$studio:{isSelected:b,select:v,setSelectionTarget:L}}),[p,v,b]);return c(()=>{w(e=>{let o={};for(let s in l.value)e[s]?o[s]=e[s]:o[s]=M(l.value[s]);return o})},[l]),c(()=>l.onValuesChange(o=>{for(let s in o)p[s]&&p[s].set(o[s])}),[l,p]),c(()=>{V(u.object(r,i,{reconfigure:!0}))},[i,r,u]),c(()=>{if(!t)return;let e=document.createElement("div"),o=G(e);return T({root:o,domElement:e}),()=>{o.unmount(),e.remove(),T(null)}},[t]),c(()=>{!a||!t||(h&&t.appendChild(a.domElement),a.root.render(f(H,{selectionTarget:t,selectFn:v,isSelected:b,isHovered:g,theme:m})))},[a,m,h,g,b,v,t]),c(()=>{let e=s=>{s.altKey===!0&&j(!0)},o=s=>{s.altKey===!1&&j(!1)};return document.addEventListener("keydown",e),document.addEventListener("keyup",o),()=>{document.removeEventListener("keydown",e),document.removeEventListener("keyup",o)}},[]),c(()=>{if(!h||!a||!t)return;t.appendChild(a.domElement);let e=t.style.position;return t.style.position=/static|^$/.test(e)?"relative":e,()=>{try{t.removeChild(a.domElement)}catch{}t.style.position=e}},[h,a,t]),c(()=>{if(!t)return;let e=()=>C(!0),o=()=>C(!1);return t.addEventListener("mouseenter",e),t.addEventListener("mouseleave",o),()=>{C(!1),t.removeEventListener("mouseenter",e),t.removeEventListener("mouseleave",o)}},[t]),c(()=>{if(!t)return;let e=o=>{h&&(o.stopPropagation(),v())};return t.addEventListener("click",e),()=>{t.removeEventListener("click",e)}}),O}function B(){let{sheet:r}=S(E);return r.sequence}function H({selectFn:r,isSelected:i,isHovered:u,theme:n}){return f("div",{style:{position:"absolute",inset:0,pointerEvents:"none",borderWidth:n.width,borderStyle:i?"solid":"dashed",borderColor:i||u?n.selectedColor:n.normalColor,boxSizing:"border-box",zIndex:1e3},onClick:r})}export{D as TheatreProvider,B as useControls,q as useSheetObject,N as withTheatre}; | ||
//# sourceMappingURL=main.js.map |
@@ -18,3 +18,3 @@ { | ||
"homepage": "https://github.com/AndrewPrifer/framer-motion-theatre", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"type": "module", | ||
@@ -41,5 +41,5 @@ "files": [ | ||
"@theatre/studio": "^0.7.2", | ||
"framer-motion": "^10.18.0", | ||
"react": "^18.0.0", | ||
"react-dom": "^18.0.0" | ||
"framer-motion": ">10", | ||
"react": "18.0.0 - 19.x", | ||
"react-dom": "18.0.0 - 19.x" | ||
}, | ||
@@ -57,3 +57,3 @@ "devDependencies": { | ||
"eslint-plugin-react-refresh": "^0.4.5", | ||
"framer-motion": "^10.18.0", | ||
"framer-motion": "^11.2.10", | ||
"leva": "^0.9.35", | ||
@@ -60,0 +60,0 @@ "react": "^18.2.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44748