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

Independent delta not working in .then #265

Open
strukteon opened this issue Apr 14, 2022 · 4 comments
Open

Independent delta not working in .then #265

strukteon opened this issue Apr 14, 2022 · 4 comments
Labels
bug bug to fix

Comments

@strukteon
Copy link

It seems like independent deltas don't work in .then() functions.

I am trying to create a jump animation using this code:

const circle = new mojs.Shape({
  top: 40,
  left: 40,
  y: {
    0: 100,
    easing: "cubic.out"
  },
  x: {
    0: 20,
    easing: "linear.none"
  },
  radius: 40,
  duration: 250,
}).then({
  y: {
    100: 0,
    easing: "cubic.in"
  },
  x: {
    20: 40,
  }
});

When adding any of the independent delta properties specified in https://mojs.github.io/api/modules/html/#independent-deltas, the .then() is ignored altogether.

Am I using it improperly or is there any fix for this?

@Sandstedt
Copy link
Member

@strukteon Could you create a Codepen for us to test? But I think the problem here is the 0. If I remember correctly, if the key is a zero or negative values, you need to define it as a string instead of a number.

So "0" : "100"

@strukteon
Copy link
Author

Weirdly enough, the value 0 works when not specifying any easing parameters. Also, some properties (like scale) can be used with a separate easing function.

Here's the codepen: https://codepen.io/strukteon-the-vuer/pen/jOYeBex

@xavierfoucrier
Copy link
Member

Hi @strukteon,

Good catch, I confirm it's a bug!

You can workaround using a "global" easing define at the root of then, like this:

const scale = new mojs.Shape({
  top: 200,
  left: 500,
  scale: {
    0: 3,
    easing: "elastic.out"
  },
  x: {
    0: 200
  },
  radius: 40,
  duration: 1500
}).then({
  easing: "elastic.out", // x later will use this easing
  scale: {
    3: 1,
    easing: "cubic.in" // scale will properly use this easing
  },
   x: {
    200: 0
    // specifying an easing here won't work at all
  }
});

For the moment, I am not seeing any other workaround for this case, or you may need to build your animation in a different way.

@xavierfoucrier xavierfoucrier added the bug bug to fix label Apr 15, 2022
@strukteon
Copy link
Author

@xavierfoucrier Alright, thanks! 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug bug to fix
Projects
None yet
Development

No branches or pull requests

3 participants