Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change animation direction, pause animations, move animation to a key frame, change animation easing functions #65

Open
sparksflyupwards opened this issue Jan 3, 2023 · 4 comments
Labels
feature-request New feature or request idea

Comments

@sparksflyupwards
Copy link

No description provided.

@sparksflyupwards
Copy link
Author

Would be happy to work/collaborate on this if it isn't already in the works!

@stevenpetryk stevenpetryk added feature-request New feature or request idea labels Jan 3, 2023
@stevenpetryk
Copy link
Owner

What would some of these APIs look like to you, ideally?

@gsspdev
Copy link

gsspdev commented Jan 3, 2023

I am also interested in working on this. I have some ideas in mind of how to implement these features

@sparksflyupwards
Copy link
Author

sparksflyupwards commented Jan 4, 2023

What would some of these APIs look like to you, ideally?

one approach would be to add an 'animationSettings' object to the Stopwatch interface. Then users can configure properties such as reversed, repeats, ease function, etc... An enum of different Easing options could also be included.

So for example if a user wanted a repeating animation with a "bounce" ease effect they may do as follows:

import { Mafs, useStopwatch, Easing } from "mafs"

function AnimatedPoint() {
  const { time, start, animationSettings} = useStopwatch();

  React.useEffect(() => {
    animationSettings = {
      ease: Easing.bounce
      repeats: true,
    };
    start();
  }, [start]);

...

However, if repeating animations are included, this would require a definite animation length. As an example a user could configure a reversed and repeating animation of 10 seconds like so:

function AnimatedPoint() {
  const { time, start, animationSettings } = useStopwatch();

  React.useEffect(() => {
    animationSettings = {
      ...animationSettings,
      length: 10,
      reversed: true,
      repeats: true,
    };
    start();
  }, [start]);

...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request idea
Projects
None yet
Development

No branches or pull requests

3 participants