Interesting I have figured out the reason why your example didn't work(and
now does). It doesn't work when you have elements in the array which don't
need animation/are in the same state initially as the final animation state.
So I now have an active class indicating it's state and the selector I
Strange. In my tests the last element's callback was always called
last. jQuery's animations are time-based, that means both animations
should end at the same time, with a small offset for the last element
at most.
Anyway, you already have a solution. I had first rewritten yours
before trying the
Thats cool thanks Brian and Ricardo for your time.
Ricardo that did look really good but it doesn't work for me.
jQuery("div.mainLiner div.panel").not(':last')
.slideUp(750, function(){
console.log("not last");
}).end()
.filter(':last')
.slideUp(750, function(){
console.log("last");
//callback
}
You're right, that will run the callback once for each element. This
is a bit hacky but is the shortest way I could think of:
function closeMainPanels(){
jQuery("div.mainLiner div.panel").not(':last').slideUp(750).end()
.filter(':last').slideUp(750, function(){
//callback
They are all sliding up at the same time, but I was under the impression
that your code would call the callback function once for each div.panel that
was found. Am I mistaken?
(would be really awesome if it does only call once)
And if I'm not, I reiterate that I only want the callback function cal
If they are all sliding up at the same time, isn't it simpler to use
function closeMainPanels(){
jQuery("div.mainLiner div.panel").slideUp(750, function(){ /
*...callback...*/ });
}
On Jan 1, 5:53 pm, "Cam Spiers" wrote:
> function closeMainPanels(callback){
> var panels = jQuery('div.m
function closeMainPanels(callback){
var panels = jQuery('div.mainLiner div.panel');
var done = [];
var length = panels.length;
panels.each(function(){
var panel = jQuery(this);
panel.slideUp(750, function(){
if (done.push(panel) == length){
Thanks for your response.
Yes I have used that before, but I need to know how to add a callback
function which is called after a set of animations are completed.
If I have an array of dom elements which all need the same animation applied
to them,
how can I tell when all the animations are comple
On Wed, Dec 31, 2008 at 11:26 PM, Cam Spiers wrote:
> Hey,
>
> function closeMainPanels(){
> jQuery("div.mainLiner div.panel").each(function(){
> jQuery(this).slideUp(750);
> });
> }
>
> How can I tell when all panels have finished animation?
>
> As I need to call another function
9 matches
Mail list logo