Last active
July 8, 2018 17:46
-
-
Save thomasnield/c7bbb37d4b238204d91a63a2d2f09089 to your computer and use it in GitHub Desktop.
DequeTransition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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() | |
| } | |
| ) | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.