Comments (3)
Yeah this is great - I actually wanted to look into extending useTransform
to do multiple values but I hadn't thought about stuff like this 🥳
I think my most prefered API would possibly be
useTransform([xA, xB], ([a, b]) => (a + b) / 2)
// Maybe later
useTransform({ x: xA, y: xY }, ({ x: a, y: b}) => (a + b) / 2)
As I see it basically does accept a transform function. I'd like to consider how this would work with array syntax as well.
from motion.
Is an extension of useTransform
to support multiple input MotionValues
still something planned for the future of framer-motion
?
Edit: included my own hook to solve this problem (based on the one @steveruizok included in his branch); it's working great
from motion.
Makes sense to me! Array syntax sounds like 2D interpolation (ie this kind of thing) which could get interesting but feels different than the current array syntax for useTransform
.
I could imagine using the proposed syntax with 2D arrays, though.
const getDistance = ([x1, y1], [x2, y2]) => Math.hypot(x2-x1, y2-y1)
const distance = useTransform([[xA, yA], [xB, yB]], getDistance)
from motion.
Related Issues (20)
- [BUG] It isn't possible to animate the `x` and `y` coordinates of an SVG element using `animate` HOT 1
- [BUG] Framer Motion Animation doesn't work on reload without delay HOT 6
- [BUG] LazyMotion sets `initial` immediately; before `LazyMotion.features` load
- [BUG] with new version 11.0.24 HOT 3
- [FEATURE] Expose moved item index in Reorder.group
- ref prop does not work on div directly inside AnimatePresence with mode="popLayout" [BUG] HOT 1
- how to jump to specific position in animation sequence?
- [BUG] ScaleZ doesn't get applied to the motion component
- [BUG] problems with useMotionValue and useSpring to make an object follow the cursor after v11.
- [BUG] RotateZ not working in Shared Layout Animation HOT 2
- [BUG] v11 breaks all animations using vh and dvh as css unit HOT 1
- [BUG] v11 regression when cloning `motion` components HOT 2
- [BUG] Blinking on Enter and Exit Animations with layoutId and AnimatePresence
- [BUG] AnimatePresence - enter and exit animations are mixed when they alternate rapidly HOT 5
- [BUG] When resizing a canvas with a LayoutCamera, pointer events on meshes are aligned incorrectly.
- [BUG] Elements do not animate in latest React 19 canaries HOT 6
- [BUG] ReferenceError: React is not defined Just by importing framer-motion HOT 3
- [BUG] Docs: Application error: a client-side exception has occurred (see the browser console for more information). HOT 1
- [BUG] Property '$$typeof' is missing in `ForwardRefComponent` HOT 2
- [BUG] Next.js render error when first loaded
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from motion.