aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.effects.explode.js
diff options
context:
space:
mode:
authorgnarf <gnarf@gnarf.net>2011-03-10 22:18:19 -0600
committergnarf <gnarf@gnarf.net>2011-03-10 22:18:19 -0600
commit4ade64b69028178772d0b9c11fbf7165de160972 (patch)
treeeb92cc06717712bab0329d0d50f97624c6a9ea5a /ui/jquery.effects.explode.js
parent19e72449f16dca7c2bca82ea830165ea0183ed36 (diff)
downloadjquery-ui-4ade64b69028178772d0b9c11fbf7165de160972.tar.gz
jquery-ui-4ade64b69028178772d0b9c11fbf7165de160972.zip
effects.*: Explode effect was removing more elements than it should upon completion. Fixed #6022 - multiple explosions cut short
Diffstat (limited to 'ui/jquery.effects.explode.js')
-rw-r--r--ui/jquery.effects.explode.js36
1 files changed, 22 insertions, 14 deletions
diff --git a/ui/jquery.effects.explode.js b/ui/jquery.effects.explode.js
index 763092457..79cf1a9fb 100644
--- a/ui/jquery.effects.explode.js
+++ b/ui/jquery.effects.explode.js
@@ -14,7 +14,7 @@
$.effects.explode = function( o ) {
- return this.queue( function() {
+ return this.queue( function( next ) {
var rows = o.pieces ? Math.round(Math.sqrt(o.pieces)) : 3,
cells = rows,
@@ -22,12 +22,14 @@ $.effects.explode = function( o ) {
mode = $.effects.setMode( el, o.mode || 'hide' ),
offset = el.offset(),
width = el.outerWidth( true ),
- height = el.outerHeight( true );
+ height = el.outerHeight( true ),
+ peices = [];
//Substract the margins - not fixing the problem yet.
offset.top -= parseInt( el.css( "marginTop" ), 10 ) || 0;
offset.left -= parseInt( el.css( "marginLeft" ), 10 ) || 0;
+ // clone the element for each row and cell.
for( var i = 0; i < rows ; i++ ) { // =
for( var j = 0; j < cells ; j++ ) { // ||
el
@@ -54,23 +56,29 @@ $.effects.explode = function( o ) {
left: offset.left + j*(width/cells) + (o.mode == 'show' ? 0 : (j-Math.floor(cells/2))*(width/cells)),
top: offset.top + i*(height/rows) + (o.mode == 'show' ? 0 : (i-Math.floor(rows/2))*(height/rows)),
opacity: mode == 'show' ? 1 : 0
- }, o.duration || 500);
+ }, o.duration || 500, childComplete );
}
}
- // Set a timeout, to call the callback approx. when the other animations have finished
- setTimeout(function() {
+ // children animate complete:
+ function childComplete() {
+ peices.push( this );
+ if ( peices.length == rows * cells ) {
+ animComplete();
+ }
+ }
+ function animComplete() {
el.css({ visibility: 'visible' });
- mode != 'show' && el.hide();
- $.isFunction( o.complete ) && o.complete.apply( el[ 0 ] );
- el.dequeue();
-
- // Note: This is removing all exploding peices from the dom, rather than the ones for this animation only... Ticket# 6022
- $('div.ui-effects-explode').remove();
- }, o.duration || 500);
-
-
+ $( peices ).remove();
+ if ( mode != 'show' ) {
+ el.hide();
+ }
+ if ( $.isFunction( o.complete ) ) {
+ o.complete.apply( el[ 0 ] );
+ }
+ next();
+ }
});
};