Modify ↓
Ticket #8551 (closed bug: invalid)
.animate() callback function executed immediately if the function has .apply()
| Reported by: | anonymous | Owned by: | |
|---|---|---|---|
| Priority: | undecided | Milestone: | 1.next |
| Component: | unfiled | Version: | 1.5.1 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
$('#id').animate(
{
'height':'toggle'
}, 5000, 'linear', function(){
console.log(1)
}.apply(this)
});
This function would console.log(1) when the animation starts instead of when it is complete. This is down to the .apply() as when it is removed the callback executes at the correct moment.
Change History
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.

I agree with your analysis, which is why this code is not related to any jQuery problem. It is explicitly running the function immediately rather than passing a function object to .animate() for later callback.