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

anim.begin callback never called if anim.delay is a function #79

Closed
singuerinc opened this issue Sep 23, 2016 · 6 comments
Closed

anim.begin callback never called if anim.delay is a function #79

singuerinc opened this issue Sep 23, 2016 · 6 comments

Comments

@singuerinc
Copy link

Since begin is executed when time.current >= s.delay then if s.delay is a function the statement always return false.

https://github.com/juliangarnier/anime/blob/master/anime.js#L550

I'm trying to animate multiple objects and return a delay based on the index:

anime({
  targets: "ul li",
  begin: (animation) => console.log("begin"),
  opacity: [0, 1],
  duration: 1500,
  delay: (el, index) => 25 * index
});

Check out this test I have made:
http://codepen.io/singuerinc/pen/jrBVdJ

My example is not complicated to solve since is using the index, but I'm not sure how to solve it, for instance, if you use a more complex calculation.

@alexchantastic
Copy link
Contributor

alexchantastic commented Oct 4, 2016

I am seeing the same issue. However, if it is a named function, it is called. For example,

function foo() {
     // stuff here
};

anime({
    targets: '#foo',
    begin: foo()
});

This does not give access to the animation object though.

@singuerinc
Copy link
Author

@alexchantastic that's incorrect, is not anime that is calling the function, is you when you write foo().
You should write just begin: foo without ()

@alexchantastic
Copy link
Contributor

@singuerinc yes, you're correct, but I think foo will still be executed at the correct time. This is just a workaround. I suppose it's no different than:

foo();
anime({...});

@juliangarnier
Copy link
Owner

Will look at this later, thanks for pointing this out!

@alexchantastic
Copy link
Contributor

@juliangarnier I've proposed a fix for this in PR #88.

@juliangarnier
Copy link
Owner

fixed in v1.1.2

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

No branches or pull requests

3 participants