I’ve seen the .filter() and .end() calls in a chain which leads me to believe that this is possible. So I’ve made my own function that can be added to the chain rawr()
$('#object').fadeIn().rawr().delay(1000).fadeOut();
I want rawr() to see what is coming up next and depending on what it is, allow execution to continue or to end the chain and move to the next line of code. How is this done?
You can’t get the next jQuery function in the chain of called functions directly without parsing the JavaScript source itself.
Given your comment:
You’ll want to use the
queuemethod to store a function in thefxqueue. When the custom function is executed, thefxqueue will have queued all the animations in the jQuery chain.Within your custom function you’d be able to access the
fxqueue and check what’s been queued. You’d also be able to callclearQueueto remove any of the queued functions before dequeuing thefxqueue.It’s necessary to dequeue the custom queued function as the
fxqueue wont continue for any other queued functions until the currently executing function has indicated that it’s finished.That all being said, it sounds like you should break your chain and conditionally execute methods, rather than trying to chain animations that are simply cleared later.