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

Returning a Promise #19

Closed
JSteunou opened this Issue Feb 9, 2016 · 3 comments

Comments

Projects
None yet
4 participants
@JSteunou

JSteunou commented Feb 9, 2016

Hi,

first thank you first this jewel, really a saviour!

Could you consider returning a Promise from animate call?

Would solve #6 and allow use of future async / await out of the box.

@jhabdas

This comment has been minimized.

jhabdas commented Apr 11, 2017

Agreed. The amount of spaghetti code I wrote trying to do a simple headline rotation sequence has lead me to giving animo a shot instead (it returns a promise, but uses a different approach).

@msheakoski

This comment has been minimized.

msheakoski commented May 15, 2017

What about using a simple wrapper?

function pranimate(params) {
  return new Promise(function (resolve, reject) {
    params.complete = resolve;
    animate(params);
  });
}
<h1>Hello</h1>
<script> 
  document.addEventListener("DOMContentLoaded", function(event) {    
    pranimate({
      el: "h1",
      translateX: [0, 200],
      duration: 1000
    }).then(function () {
      return pranimate({
        el: "h1",
	translateX: [200, 200],
        translateY: [0, 200],
        duration: 1000
      });
    }).then(function () {
      return pranimate({
        el: "h1",
	translateX: [200, 0],
        translateY: [200, 200],
        duration: 1000
      });
    }).then(function () {
      return pranimate({
        el: "h1",
        translateY: [200, 0],
        duration: 1000
      });
    });
  });
</script>
@bendc

This comment has been minimized.

Owner

bendc commented Nov 27, 2017

Fixed in v2.0.0

@bendc bendc closed this Nov 27, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment