@apsillers , , iPad, . , .
The requirement, apparently, is that the call play()can only be inside one setTimeout(Therefore, the simplified example that I gave in the original question really works - initially I had a play()few setTimeoutdeep ones).
So this will work:
constructor: (@_button, @_audio) ->
@_button.on 'click', @_play
_play: (e) =>
setTimeout (=>
@_audio[0].play() // play() is only inside one setTimeout
), 300
And this will also work:
constructor: (@_button, @_audio) ->
@_button.on 'click', =>
setTimeout ((e) =>
@_play(e)
), 300
_play: (e) =>
@_audio[0].play() // Still only inside one setTimeout
But this will not work:
constructor: (@_button, @_audio) ->
@_button.on 'click', @_play
_play: (e) =>
setTimeout (=>
// Something useful
setTimeout (=>
@_audio[0].play() // play() is inside two setTimeouts
), 300
), 300
And this will be (my original setup):
constructor: (@_button, @_audio) ->
@_button.on 'click', @_play
_play: (e) =>
@_button
.animate { prop: value }, 300, =>
setTimeout (=>
@_audio[0].play() // play() still 'too deep'
), 300
In the last example, it seems that jQuery animate callback is being called from another setTimeoutinside the library, so play()again "too deep".