Transition between two points using a curve/arch/path #4032
Unanswered
AdamGerthel
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Couldnt find anything so came up with a cubic beziar worklet function. I first tried to coopt the reanimated bezier functions but that didnt work. T = a shared value that animates from 0 -> 1 function quadraticBezier(t, point0, point1, point2) {
'worklet';
const oneMinusT = 1 - t;
const oneMinusTSquared = oneMinusT * oneMinusT;
const tSquared = t * t;
const x =
oneMinusTSquared * point0.x +
2 * oneMinusT * t * point1.x +
tSquared * point2.x;
const y =
oneMinusTSquared * point0.y +
2 * oneMinusT * t * point1.y +
tSquared * point2.y;
return { x, y };
} Hope this helps! |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to animate an element along a curve, like the numbers in the below example:
As you can see, the number (36 in this case) scales down (to point of origin, I think) and then travels along a curved path either to the left or to the right as it fades away.
I've tried to achieve this using keyframes but it doesn't seem to be possible to do. I've tried all kinds of easings but I think I've reached the conclusion that easings will never be able to solve it, because the element will still only travel in a straight line between the points/coordinates that I set up - i.e. it will never travel in a natural looking arch.
Here's an example of what I've managed to achieve so far:
But as you can see, it doesn't look as natural.
I've been searching everywhere for an answer to this but have so far not been able to find what I'm looking for. Is this possible to do with reanimated, and if so - how? Is there a keyword I'm missing when I'm searching for solutions to this? Does it have a name?
Please help! 🙏
This is my current animation:
Beta Was this translation helpful? Give feedback.
All reactions