/** fadeSwap function that batches multiple fadeSwap animations, over a creates an dn.lfx.batch.windowSize window the outDuration and inDuration are taken from the first dn.lfx.batch.fadeSwap called within the window */ dn.lfx.batch = {}; dn.lfx.batch._timer = null; dn.lfx.batch._items = []; dn.lfx.batch.windowSize = 250; dn.lfx.batch.fadeSwap = function(outNode, inNode, outDuration, inDuration) { if (!dn.lfx.batch._timer) { dn.lfx.batch._timer = setTimeout(function() { // create the animation group and start it var fadeHides = []; var fadeShows = []; var swapNodes = []; dojo.lang.forEach(dn.lfx.batch._items, function(item) { swapNodes.push({parent:item.outNode.parentNode, inNode:item.inNode}); fadeHides.push(dojo.lfx.html.fadeHide(item.outNode, item.outDuration, null)); fadeShows.push(dojo.lfx.html.fadeShow(item.inNode, item.inDuration, null)); }); var fadeHideAnim = dojo.lfx.combine(fadeHides); var fadeShowAnim = dojo.lfx.combine(fadeShows); dojo.event.connect(fadeHideAnim, "onEnd", function() { dojo.lang.forEach(swapNodes, function(swapNode) { dojo.html.replaceChildren(swapNode.parent, swapNode.inNode); }); fadeShowAnim.play(); //dojo.debug('fadeHide.onEnd'); }); dojo.event.connect(fadeShowAnim, "onEnd", function() { dojo.lang.forEach(swapNodes, function(swapNode) { dojo.html.setOpacity(swapNode.inNode, 1); }); //dojo.debug('fadeShow.onEnd'); }); // clear the batch items dn.lfx.batch._items = []; dn.lfx.batch._timer = null; fadeHideAnim.play() }, dn.lfx.batch.windowSize); } dn.lfx.batch._items.push({outNode:outNode, inNode:inNode, outDuration:outDuration, inDuration:inDuration}); }