Skip to content

Instantly share code, notes, and snippets.

@thomasnield
Last active July 8, 2018 17:46
Show Gist options
  • Select an option

  • Save thomasnield/c7bbb37d4b238204d91a63a2d2f09089 to your computer and use it in GitHub Desktop.

Select an option

Save thomasnield/c7bbb37d4b238204d91a63a2d2f09089 to your computer and use it in GitHub Desktop.
DequeTransition
import javafx.animation.Timeline
import java.util.concurrent.ConcurrentLinkedDeque
class DequeTransition {
private var _queue = ConcurrentLinkedDeque<Timeline>()
operator fun plusAssign(timeline: Timeline) {
_queue.add(
timeline.apply {
setOnFinished {
_queue.poll()?.play()
}
if (_queue.size == 0) play()
}
)
}
}
@eugener

eugener commented Jul 8, 2018

Copy link
Copy Markdown

I might misunderstand this, as I'm not as fluent in Kotlin :)
But what happens if you have more then one timeline in the queue and one more has to be added? I assumed that you have to "attach" the new one to the "onFinish" of the last one in the queue.

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