You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use framer-motion with variants, canvas and typescript. I'm not sure how to do it the correct way.
Is there a better way to write canvas or could this be a feature request for framer-motion?
Here is my working code at the moment.
constvariants: Variants={enter: {customValue1: 0,customValue2: 0,}asany,// <!--I don't want to do this.idle: {customValue1: 1,customValue2: 0,}asany,// <!-- I don't want to do this.active: {customValue1: 1,customValue2: 1,}asany,// <!-- I don't want to do this.leave: {customValue1: 0,customValue2: 0,}asany,// <!-- I don't want to do this.};constPainter=(props: PainterProps)=>{constref=useRef<HTMLCanvasElement>(null);constrender=useMemo(()=>{letctx: CanvasRenderingContext2D;return(values: ResolvedValues)=>{ctx??=ref.current?.getContext("2d");// Render stuff to canvas...};},[]);return(<motion.canvas{...props}ref={ref}variants={variants}onUpdate={(...args)=>{props.onUpdate?.(...args);render(...args);}}/>);};
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm trying to use framer-motion with variants, canvas and typescript. I'm not sure how to do it the correct way.
Is there a better way to write canvas or could this be a feature request for framer-motion?
Here is my working code at the moment.
Beta Was this translation helpful? Give feedback.
All reactions