Store callback to invoke at the end of a sequence
This commit is contained in:
parent
c7ed8bed3b
commit
64b0244972
|
@ -39,17 +39,20 @@ sequence.start = function (options, cb) {
|
||||||
} else {
|
} else {
|
||||||
sequence._loop.max = 0
|
sequence._loop.max = 0
|
||||||
}
|
}
|
||||||
|
sequence._state.stop = cb
|
||||||
sequence.step()
|
sequence.step()
|
||||||
}
|
}
|
||||||
|
|
||||||
sequence.stop = function (next) {
|
sequence.setStop = function () {
|
||||||
|
sequence._state.active = false
|
||||||
|
}
|
||||||
|
|
||||||
|
sequence.stop = function () {
|
||||||
sequence._state.active = false
|
sequence._state.active = false
|
||||||
sequence._state.count = 0
|
sequence._state.count = 0
|
||||||
sequence._loop.count = 0
|
sequence._loop.count = 0
|
||||||
console.dir(sequence._state.stop)
|
if (sequence._state.stop) sequence._state.stop()
|
||||||
console.trace()
|
sequence._state.stop = null
|
||||||
if (next) next()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sequence.pause = function () {
|
sequence.pause = function () {
|
||||||
|
@ -63,12 +66,15 @@ sequence.resume = function () {
|
||||||
|
|
||||||
sequence.step = function () {
|
sequence.step = function () {
|
||||||
if (sequence._state.active && !sequence._state.paused) {
|
if (sequence._state.active && !sequence._state.paused) {
|
||||||
if (sequence._state.arr.length > 0 && typeof sequence._state.arr[sequence._state.count] !== 'undefined') {
|
if (sequence._state.arr.length > 0) {
|
||||||
|
if (sequence._state.count > sequence._state.arr.length) {
|
||||||
|
return sequence.stop()
|
||||||
|
}
|
||||||
return sequence._state.arr[sequence._state.count](() => {
|
return sequence._state.arr[sequence._state.count](() => {
|
||||||
sequence._state.count++
|
sequence._state.count++
|
||||||
sequence.step()
|
sequence.step()
|
||||||
})
|
})
|
||||||
} else if (sequence._loop.arr.length > 0 && typeof sequence._loop.arr[sequence._state.count] !== 'undefined') {
|
} else if (sequence._loop.arr.length > 0) {
|
||||||
if (sequence._state.count > sequence._loop.arr.length) {
|
if (sequence._state.count > sequence._loop.arr.length) {
|
||||||
sequence._state.count = 0
|
sequence._state.count = 0
|
||||||
sequence._loop.count++
|
sequence._loop.count++
|
||||||
|
|
Loading…
Reference in New Issue