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

Delaying an animation #101

Closed
jonnygreen opened this issue Apr 18, 2019 · 4 comments
Closed

Delaying an animation #101

jonnygreen opened this issue Apr 18, 2019 · 4 comments

Comments

@jonnygreen
Copy link

Liquid Fire has a delay attribute that can be set to delay the start of an animation. The equivalent functionality appears to be missing in ember-animated. Is that the case, or if not, is it possible to delay an animation?

@ef4
Copy link
Contributor

ef4 commented Apr 18, 2019

I think this is best done by putting a yield timeout(ms) inside your transition function.

@jonnygreen
Copy link
Author

Thanks Ed, that makes sense.

@willviles
Copy link

Just to note that in some cases, if you're animating in transitions with a yielded timeout above the transition declarations, the animation can quickly 'flash' its initial state.

import { wait } from 'ember-animated'
export default function * ({ insertedSprites, duration }) {
  yield wait(100)
  for (let sprite of insertedSprites) {
    sprite.startAtPixel({ y: sprite.element.getBoundingClientRect().top + 20 })
    opacity(sprite, { to: 1, duration })
    move(sprite, { easing: easeOut })
  }
}

Setting an initial opacity fixes this:

export default function * ({ insertedSprites, duration }) {
  for (let sprite of insertedSprites) {
    opacity(sprite, { to: 0 })
  }
  yield wait(100)
  for (let sprite of insertedSprites) {
    sprite.startAtPixel({ y: sprite.element.getBoundingClientRect().top + 20 })
    opacity(sprite, { to: 1, duration })
    move(sprite, { easing: easeOut })
  }
}

@samselikoff
Copy link
Contributor

@willviles thanks! Opened an issue for it, want to try to start tracking these

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

4 participants